Detecting of angles

Started by FluroM, November 07, 2017, 09:37:38 AM

Previous topic - Next topic

FluroM

I am detecting angles in my code (in degrees) but when i have ege of 359 and 0 it will not work. I have minimum and maximum angle and angle of object. If you can help me i will thank you.
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
P.S. This is for stealth map.
[close]
[close]
[close]
[close]
[close]
[close]
[close]
[close]
[close]
[close]
[close]
[close]

Builder17

Quote from: FluroM on November 07, 2017, 09:37:38 AM
I am detecting angles in my code (in degrees) but when i have ege of 359 and 0 it will not work. I have minimum and maximum angle and angle of object. If you can help me i will thank you.
Spoiler
P.S. This is for stealth map.
[close]

Well, if this isn't just cruel joke, PM that code to me? It's working way to not give code away to allbody. :D

GoodMorning

Indeed. We can't help if we don't have the code. If it's a strategy-spoiler, you've warned of it already.
A narrative is a lightly-marked path to another reality.

FluroM


#angle is angle of enemy
#playerangle is angle between enemy and player
#everything is in degress and from 0 to 360

<-angle 45 add ->maxangle
<-angle 45 sub ->minangle

if(and(<-playerangle <-minangle gte <-playerangle <-maxangle lte))

Self "main" 0 255 0 255 SetImageColor #For debuging

endif


This is everything

GoodMorning

So, you want to know when a an angle is within "tolerance" of "angle".


#Using radians
:InSector
    ->Tolerance ->AngleB ->AngleA

    <-AngleB <-AngleA ShortestAngle abs <-Tolerance lt


ShortestAngle requires the angles to be measured in radians. However, it is the easiest (and most efficient) solution to your problem.


<-angle <-playerangle PI 2 div @InSector if
    #Code
endif
A narrative is a lightly-marked path to another reality.