Virtual Line linking 2 objects
#6

You could also use angles for a approximation

Both objects are imaginary viewing each other, if X and Y are in both "viewing angles" of the objects the player is between them (the viewing angle is given by the parameter degrees * 2)

Resulting that the detection area looks like a rhombus obj1<>obj2
pawn Код:
stock IsBetweenXY(Float: X, Float: Y, Float: X1, Float: Y1, Float: X2, Float: Y2, Float: deg = 5.0) {
    return (
        (-deg <= (atan2(X2 - X1, Y2 - Y1) - atan2(X - X1, Y - Y1)) <= deg) &&
        (-deg <= (atan2(X1 - X2, Y1 - Y2) - atan2(X - X2, Y - Y2)) <= deg)
    );
}
Reply


Messages In This Thread
Virtual Line linking 2 objects - by Battlezone - 26.03.2015, 13:16
Re: Virtual Line linking 2 objects - by fuckingcruse - 26.03.2015, 14:47
Re: Virtual Line linking 2 objects - by JaydenJason - 26.03.2015, 15:23
Re: Virtual Line linking 2 objects - by Pottus - 26.03.2015, 15:44
Re: Virtual Line linking 2 objects - by Battlezone - 26.03.2015, 16:33
AW: Virtual Line linking 2 objects - by Nero_3D - 26.03.2015, 17:38
Re: Virtual Line linking 2 objects - by Pottus - 26.03.2015, 17:44
AW: Virtual Line linking 2 objects - by Nero_3D - 26.03.2015, 19:34
Re: Virtual Line linking 2 objects - by Battlezone - 26.03.2015, 20:02
Re: Virtual Line linking 2 objects - by Pottus - 26.03.2015, 20:25

Forum Jump:


Users browsing this thread: 1 Guest(s)