• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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