• 🏆 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!

Unit is In Front Of Me

Status
Not open for further replies.
Level 10
Joined
Jan 21, 2007
Messages
576
Alright i need to know how to make a conidition checkng if a point is in front of a unit. Kind of the oposite of checking if a unit is behind you to backstab.

In the attached file the arrow is the way the unit is faceing, i want to check if a point is within the angles extending from the unit.
 

Attachments

  • Example.jpg
    Example.jpg
    3.9 KB · Views: 112
Level 10
Joined
Nov 10, 2004
Messages
351
http://www.wc3jass.com/viewtopic.php?t=146 Link to IsAngleBetweenAngles() function
  • Custom script: local unit caster
  • Custom script: local real x
  • Custom script: local real y
  • Custom script: local real facing=GetUnitFacing(caster)
  • Custom script: if IsAngleBetweenAngles(Atan2(y-GetUnitY(caster), x-GetUnitX(caster)), facing+90, facing-90) then
  • //actions here
  • Custom script: endif
Will do the actions placed within the if, if the point 'x,y' is infront of caster.
 
Status
Not open for further replies.
Top