|
|
#1 |
|
User
Join Date: Aug 2003
Posts: 104
|
I have a black hole-type spell and want units to spiral into it.
I have the following code 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)) 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? Last edited by marshall : 04-28-2009 at 08:52 PM. |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#2 |
|
Lackadaisically Absent.
Respected User
|
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...
__________________ |
|
|
|
|
|
#3 |
|
User
Join Date: Aug 2003
Posts: 104
|
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. Last edited by marshall : 04-30-2009 at 12:07 PM. |
|
|
|
|
|
#4 |
|
Lackadaisically Absent.
Respected User
|
Recode it from the ground up, then. There could be some weird error you've got that shouldn't be there.
__________________ |
|
|
|
|
|
#5 |
|
requires vJass
Code Moderator
|
If you post a demo map it would be much easier to fix.
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |