• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Change location by distance towards degrees

Status
Not open for further replies.
Hey everyone. I have a simple math problem where I want to change the location of a unit without creating or destroying locations:
  • Set MeatHChainX[MeatHRef] = (MeatHChainX[MeatHRef] + (MeatHSpeed[MeatHRef] x (Cos(MeatHDeg[MeatHRef]))))
  • Set MeatHChainY[MeatHRef] = (MeatHChainY[MeatHRef] + (MeatHSpeed[MeatHRef] x (Sin(MeatHDeg[MeatHRef]))))
  • Custom script: call SetUnitX(udg_MeatHHead, udg_MeatHChainX[udg_MeatHRef])
  • Custom script: call SetUnitY(udg_MeatHHead, udg_MeatHChainX[udg_MeatHRef])
The unit only wants to go NE or SW instead of changing X and Y by the desired amount. I searched the web for a solution but there are so many questions around polar projection that it is difficult to find the answer I'm looking for. Help will be appreciated.

EDIT: Nevermind I've found the problem. I used the wrong variable in the SetUnitY() function. I feel like an idiot... XD
 
Level 6
Joined
Jun 18, 2004
Messages
119
looks at your last two lines, you're using X in both ;)

Custom script: call SetUnitX(udg_MeatHHead, udg_MeatHChainX[udg_MeatHRef])
Custom script: call SetUnitY(udg_MeatHHead, udg_MeatHChainX[udg_MeatHRef]) => should be Y, of course :)
 
Status
Not open for further replies.
Top