- Joined
- Sep 21, 2007
- Messages
- 517
ok, im doing a game where, if shooting is initiated, the units face is close to the angle between the shooting units position and the being shooted's position. Here is what i did for the comparison:
i had a variable as a "degree boundary",
lets say (im doing this in radians, but can do it in degrees if you want me to)
so i put the units facing in a variable and converted it to Radians,
and then got the angle in a variable and left it as is (since its already radians). Now here is the comparison part:
facing being the facing, angle being the angle between the units, from the shooting unit to the unit being shooted: i used
. Sorry had to use some JASS here just incase you didnt know, its fairly basic though and can be understood through logic.
thanks for your time
i had a variable as a "degree boundary",
JASS:
degBoundary = .65
lets say (im doing this in radians, but can do it in degrees if you want me to)
so i put the units facing in a variable and converted it to Radians,
JASS:
facing = Deg2Rad(GetUnitFacing(udg_PlayerHero[unitId]))
and then got the angle in a variable and left it as is (since its already radians). Now here is the comparison part:
JASS:
if facing > angle+degBoundary or facing < angle-degBoundary then
facing being the facing, angle being the angle between the units, from the shooting unit to the unit being shooted: i used
JASS:
Atan2(y2-y,x2-x)
. Sorry had to use some JASS here just incase you didnt know, its fairly basic though and can be understood through logic.
thanks for your time