Making an object face a player - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Making an object face a player (
/showthread.php?tid=333273)
Making an object face a player -
MP2 - 10.04.2012
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.
Re: Making an object face a player -
Kar - 11.04.2012
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
Re: Making an object face a player -
MP2 - 11.04.2012
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.
Re: Making an object face a player -
Kar - 11.04.2012
try this..
http://forum.sa-mp.com/showthread.ph...3D#post1498305
Re: Making an object face a player -
MP2 - 12.04.2012
RyDeR`s function works great, thank you very much.