| 05-28-2008, 07:05 PM | #1 |
This is for a JumpPad form of trigger. If a unit enters within range, he 'jumps' forwards in the angle entered. Question: Whats the easiest method of getting the entering angle of an entering unit? As far as I know theres is no GetUnitEntered() for the unit being approached, only GetTriggerUnit() for the unit being entering. Ideally I'd just like to get, both units, calculate angle & do the jump part, but having difficulty on finding a short/simplistic method to get the unit being approached. Note: there are multiple Jump Pads across the map. The only 2 methods I can think of are: - Have a rect over each jump pad, then loop through each rect checking if it contains entering unit - Place jump pads in an array, then loop through each jump pad, measuring the distance from entering unit. Shortest range = your pad I'm currently going with the 2nd method, just wanted to check if there is a better method or perhaps something I missed? |
| 05-28-2008, 07:31 PM | #2 |
Well... use JASS and a struct attachment system to create a trigger for each Jump Pad? JASS:library jumppad needs ABC globals private constant integer RANGE = 512 // Well, I don't know! It's your jump pads! :P endglobals private struct data unit pad endstruct private function OnEnter takes nothing returns nothing local data d = GetTriggerStructA(GetTriggeringTrigger()) // d.pad is the jump pad. // GetTriggerUnit() is, as you said, the unit who comes within range. endfunction private function Loop takes nothing returns nothing local trigger trg=CreateTrigger() local data d=data.create() set data.pad=GetEnumUnit() call SetTriggerStructA(trg,d) call TriggerRegisterUnitInRange(trg, GetEnumUnit(), RANGE, null) call TriggerAddAction(trg, function OnEnter) set trg=null endfunction public function Init takes group jumppadgroup returns nothing call ForGroup(jumppadgroup, function Loop) endfunction endlibrary |
| 05-28-2008, 07:34 PM | #3 |
Yea, Emjlr3 just told me that lol. Is there a link anywhere to CS Data? |
| 05-28-2008, 07:40 PM | #4 |
I used ABC for the example (faster than CS Data). How much do you know about JASS? Do you need a working piece of code for CS Data; or can you modify it by yourself? |
| 05-28-2008, 07:48 PM | #5 |
Ah, in that case thx & I'll just dl ABC :p |
| 05-29-2008, 12:36 AM | #6 |
Don't be surprised if your entry events are delayed, especially if you have triggered movement that makes units move faster than normal. Also the idea that CSData is slower than ABC is wrong, at least not the newest CSData. |
| 05-29-2008, 12:47 AM | #7 |
I made the jump pads by just picking all units of the jumpad types, and then create trigger. add events of unit get in range to all these pads. That will do it. I used a timer or more like my own timer system to estimate the moving direction+speed, then i throw it in tat direction. The timer had to be axact so ti react fast, i had a timer tat checks for 0.02 seconds to check the unit movement. So technically it check the current unit's position when it enter, and 0.02 seconds later it check for the next position, and then calculate the direction. 0.01 also work but sometime its soo small tat it just make tat 0 direction. |
| 05-29-2008, 08:19 AM | #9 |
You should be using vector math for this. Compute their velocity moving into the pad then add the pad boost velocity to it. |
| 05-29-2008, 12:31 PM | #10 |
CSData is in the caster system, use it over abc, since there is a lot less over head, its easier to use, and since your not an idiot also I think Mads idea is not a bad one, how weer you going to get moving direction, facing angle? that is terribly sporadic, and not a good estimate |
| 05-29-2008, 12:54 PM | #11 |
He wouldn't need an angle as he always knows what direction the unit is moving in, by having old x/y and new x/y periodically. Hmm, well I used ABC & works fine atm, perhaps I'll switch to CSData but little reason now. |
| 05-29-2008, 12:59 PM | #12 |
any attachment system that uses anything more then an H2I() - 1024*1024 is simply superfluous |
| 05-29-2008, 01:30 PM | #13 |
my estimation will also make it possible for example uf u get push into a pad, u will be thrown away in tat direction u were moving, regardless of ur facing angle. And u can also limit the omni part by using some multiplications on the direction angle |
| 05-29-2008, 01:46 PM | #14 |
I don't think there's any good reason to pick either of them (CSData or ABC/other custom hashes) |
| 05-29-2008, 03:03 PM | #15 |
i use regions with local groups on it. And periodical timer 0.1 RegisterUnitInRange - is shit btw ^^ 0.15 sec delay etc... |
