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

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