Making an object face a player
#1

So I wanted to make the SAM sites work at Area 69, and I want the rocket to face the player on ALL axis. Could someone give me a function for this? I'm totally useless with maths.

Cheers.
Reply
#2

all axis?

do you know this means calculating x, y and z angle?

players and vehicles don't have x and y angle, only z angle. Unless you can work with GetVehicleRotationQuat.

pawn Код:
stock Float:Angle2D(Float:PointAx, Float:PointAy, Float:PointBx, Float:PointBy)
{
    new Float:Angle;
    Angle = -atan2(PointBx - PointAx, PointBy - PointAy);
    return Angle;
}

SetObjectRotation( playerid, x, y, Angle2D( objectx, objecty, attackingx, attackingy ));
That's for Z angle, good luck.

Try searching for quat to eular functions
Reply
#3

I never said vehicles/players have an x/y angle. I want to set an OBJECT'S rx ry rz angles to face a set of COORDINATES, i.e. a PLAYER. I want to make the rocket object face the target player.
Reply
#4

try this..

http://forum.sa-mp.com/showthread.ph...3D#post1498305
Reply
#5

RyDeR`s function works great, thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)