• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] How to get camera angle
#1
Question 
I would like to know how to get camera angle. Player camera.
Code:
Discord: Marllun#6297
  Reply
#2
https://open.mp/docs/scripting/functions...rCameraPos
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#3
(2020-11-30, 04:43 PM)Pinch Wrote: https://open.mp/docs/scripting/functions...rCameraPos





Isn't the angle, I would like how to get the angle, this is position.
Code:
Discord: Marllun#6297
  Reply
#4
I found, the codes:

Code:
stock SetPlayerLookAtPos(playerid, Float:pos_x, Float:pos_y)

{

? ? new

? ? Float:w_px,

? ? Float:w_py,

? ? Float: angle;



? ? GetPlayerPos(playerid, w_px, w_py, angle);

? ? angle = floatabs(atan((pos_y-w_py)/(pos_x-w_px)));



? ? if (pos_x <= w_px && pos_y >= w_py)

? ? angle = floatsub(180.0, angle);

? ? else if (pos_x < w_px && pos_y < w_py)

? ? angle = floatadd(angle, 180.0);

? ? else if (pos_x >= w_px && pos_y <= w_py)

? ? angle = floatsub(360.0, angle);

? ?

? ? angle = floatsub(angle, 90.0);



? ? if (angle >= 360.0)//Prevent angle more than at 360?

? ? angle = floatsub(angle, 360.0);

? ?

? ? SetPlayerFacingAngle(playerid, angle);

? ? return 1;

}



stock GetPlayerAngleAtPos(playerid, Float:pos_x, Float:pos_y)

{

? ? new

? ? Float:w_px,

? ? Float:w_py,

? ? Float: angle;



? ? GetPlayerPos(playerid, w_px, w_py, angle);

? ? angle = floatabs(atan((pos_y-w_y)/(pos_x-w_px)));



? ? if (pos_x <= w_px && pos_y >= w_py)

? ? angle = floatsub(180.0, angle);

? ? else if (pos_x < w_px && pos_y < w_py)

? ? angle = floatadd(angle, 180.0);

? ? else if (pos_x >= w_px && pos_y <= w_py)

? ? angle = floatsub(360.0, angle);

? ?

? ? angle = floatsub(angle, 90.0);



? ? if (angle >= 360.0)//Prevent angle more than at 360?

? ? angle = floatsub(angle, 360.0);

? ?

? ? return angle;

}



stock SetPlayerLookAtObject(playerid, objectid)

{

if(!IsPlayerConnected(playerid))

return 0;



? ? new

? ? Float:w_px,

? ? Float:w_py,

? ? Float:w_ox,

? ? Float:w_oy,

? ? Float:w_oz,

? ? Float: angle;



? ? GetPlayerPos(playerid, w_px, w_py, angle);

? ? GetObjectPos(objectid, w_ox, w_oy, w_oz);



? ? angle = floatabs(atan((w_oy-w_py)/(w_ox-w_px)));



? ? if (w_ox <= w_px && w_oy >= w_py)

? ? angle = floatsub(180.0, angle);

? ? else if (w_ox < w_px && w_oy < w_py)

? ? angle = floatadd(angle, 180.0);

? ? else if (w_ox >= w_px && w_oy <= w_py)

? ? angle = floatsub(360.0, angle);

? ?

? ? angle = floatsub(angle, 90.0);



? ? if (angle >= 360.0)//Prevent angle more than at 360?

? ? angle = floatsub(angle, 360.0);

? ?

? ? SetPlayerFacingAngle(playerid, angle);

? ? return 1;

}



stock GetPlayerAngleAtObject(playerid, objectid)

{

if(!IsPlayerConnected(playerid))

return 0;



? ? new

? ? Float:w_px,

? ? Float:w_py,

? ? Float:w_ox,

? ? Float:w_oy,

? ? Float:w_oz,

? ? Float: angle;



? ? GetPlayerPos(playerid, w_px, w_py, angle);

? ? GetObjectPos(objectid, w_ox, w_oy, w_oz);



? ? angle = floatabs(atan((w_oy-w_py)/(w_ox-w_px)));



? ? if (w_ox <= w_px && w_oy >= w_py)

? ? angle = floatsub(180.0, angle);

? ? else if (w_ox < w_px && w_oy < w_py)

? ? angle = floatadd(angle, 180.0);

? ? else if (w_ox >= w_px && w_oy <= w_py)

? ? angle = floatsub(360.0, angle);

? ?

? ? angle = floatsub(angle, 90.0);



? ? if (angle >= 360.0)//Prevent angle more than at 360?

? ? angle = floatsub(angle, 360.0);

? ?

? ? return angle;

}



stock GetPlayerAngleAtObject(playerid, objectid)

{

if(!IsPlayerConnected(playerid))

return 0;



? ? new

? ? Float:w_px,

? ? Float:w_py,

? ? Float:w_ox,

? ? Float:w_oy,

? ? Float:w_oz,

? ? Float: angle;



? ? GetPlayerPos(playerid, w_px, w_py, angle);

? ? GetDynamicObjectPos(objectid, w_ox, w_oy, w_oz);



? ? angle = floatabs(atan((w_oy-w_py)/(w_ox-w_px)));



? ? if (w_ox <= w_px && w_oy >= w_py)

? ? angle = floatsub(180.0, angle);

? ? else if (w_ox < w_px && w_oy < w_py)

? ? angle = floatadd(angle, 180.0);

? ? else if (w_ox >= w_px && w_oy <= w_py)

? ? angle = floatsub(360.0, angle);

? ?

? ? angle = floatsub(angle, 90.0);



? ? if (angle >= 360.0)//Prevent angle more than at 360?

? ? angle = floatsub(angle, 360.0);

? ?

? ? return angle;

}
Code:
Discord: Marllun#6297
  Reply


Forum Jump: