• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How detect a unit is in front of you or in your back ?

Status
Not open for further replies.
Level 5
Joined
Mar 7, 2009
Messages
65
I'm trying to create different mini-game, and i can't find how to easily see if the enemy that is attacking you is attacking you in you'r back or in front of you (for example, to create a "backstab" ability, or a "parry attack in front of you" ability.)

I didn't find any easy way to do it, i tried to do maths between angle of each units but it's not a good idea.

Thanks.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • (Cos((Temp_Real_1 - (Angle from Temp_Loc_1 to Temp_Loc_2)))) Greater than (Cos(Temp_Real_2))
Temp_Real_1 = Your facing
Temp_Real_2 = Half of the angle you want to check
Temp_Loc_1 = Your position
Temp_Loc_2 = Enemy position

If you set Temp_Real_2 = 90, it will do a check of 180°, a semi circle.
 
Status
Not open for further replies.
Top