HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spiralling in - gone haywire

04-28-2009, 08:49 PM#1
marshall
I have a black hole-type spell and want units to spiral into it.
I have the following code
Collapse JASS:
set radius = dissipate * 384.00
set tarx = GetUnitX(uA)
set tary = GetUnitY(uA)
set dx = tarx - x
set dy = tary - y
set dist = SquareRoot(dx * dx + dy * dy)
set mult = dissipate + ((radius - dist) / radius) //at epicenter we will be twice as fast
set dist = dist - (mult * 1.92)
set rAngleChange = mult * 0.0314159265 //1.8 degrees means 2 seconds for 1 orbit at outer edge
set angle = Atan2(dy, dx) - rAngleChange
set tarx = x + (dist * Cos(angle))
set tary = y + (dist * Sin(angle))
"dissipate" is a value intended to decrease the power of the movement and can be in the range 0.000 to 1.000. For the majority of the effect it is set to 1.000.
x and y are the coords of the black hole
uA is a unit that is spiralling in and can never be further than radius away from x,y
The above code runs every 0.01 seconds.
The intention is that the closer the unit gets to the center, the faster they are pulled in and the faster they spiral around.
Something above is wrong, because either they are moving phenomenally fast or they are flipping 180 degrees on every iteration.
I'm hoping some trigonometry genius can tell me where my case of arsebrain lies?
04-29-2009, 08:10 AM#2
Pyrogasm
It all seems alright to me. The only thing is that I think Warcraft might have an issue with negative angles, so that could be screwing with things. However, it's not likely that that's the case, so...
04-30-2009, 12:07 PM#3
marshall
My understanding is that negative angles are only an issue for things like unit facings - they shouldn't affect the raw mathsy calculations above?

I've double checked the code above and can't for the life of me figure out why my victims are out of control. They do gradually get closer to the center, but the amount they are spinning around by is huge.
05-01-2009, 06:30 AM#4
Pyrogasm
Recode it from the ground up, then. There could be some weird error you've got that shouldn't be there.
05-01-2009, 07:22 AM#5
grim001
If you post a demo map it would be much easier to fix.