• 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.

[JASS] How to make unit move forward

Status
Not open for further replies.
Hi guys I want to move a unit forward with a timer, however I have problems with the formula ... can some one help me and tell me what is wrong?

PS: data.bomber is a bomber, the unit I want to move

JASS:
call SetUnitPosition(data.bomber, GetUnitX(data.bomber)* Cos(GetUnitFacing(data.bomber)) + (6 * Cos(GetUnitFacing(data.bomber))), GetUnitY(data.bomber)*Sin(GetUnitFacing(data.bomber)) + (6 * Sin(GetUnitFacing(data.bomber))))
 
Level 14
Joined
Nov 18, 2007
Messages
816
JASS:
call SetUnitPosition(data.bomber, GetUnitX(data.bomber) + (6 * Cos(GetUnitFacing(data.bomber))), GetUnitY(data.bomber) + (6 * Sin(GetUnitFacing(data.bomber))))
// more efficient way
// note that SetUnitX/Y() doesnt interrupt orders, while SetUnitPosition does.
call SetUnitX(data.bomber, GetUnitX(data.bomber) + (6 * Cos(GetUnitFacing(data.bomber))))
call SetUnitY(data.bomber, GetUnitY(data.bomber) + (6 * Sin(GetUnitFacing(data.bomber))))

if youre using this in a struct enivornemt save the values of Cos/Sin(unitfacing) in some variables.
 
Status
Not open for further replies.
Top