SA-MP Forums Archive
Camera - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Camera (/showthread.php?tid=274423)



Camera - Scenario - 05.08.2011

How can I set the players camera to face them?


Re: Camera - Whizion - 05.08.2011

Get their position and angle and according to that use this functions:

https://sampwiki.blast.hk/wiki/SetPlayerCameraPos
https://sampwiki.blast.hk/wiki/SetPlayerCameraLookAt


Re: Camera - Scenario - 05.08.2011

I'm not really good with camera angles and stuff. Could you explain that a little more?


Re: Camera - Kush - 05.08.2011

As there is no function to set the camera infront of the player (as I know of) have you tried Setting the player's camera position?

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
I'm not really good with camera angles and stuff. Could you explain that a little more?
As I know you might be bullshitting, I'll explain. Simply set the floats according to your positions. Easy eh'?


Re: Camera - Scenario - 05.08.2011

Quote:
Originally Posted by Kush
Посмотреть сообщение
As there is no function to set the camera infront of the player (as I know of) have you tried Setting the player's camera position?
I was going to do that but how do I determine the position/angle of the camera? It needs to be looking at them- I am trying to set up some sort of custom skin selection for my current project. I have never attempted to do this though which is why I'm not sure how to go about doing so.


Re: Camera - iPLEOMAX - 05.08.2011

Are you looking for this? I already made it once..

pawn Код:
stock SetPlayerCameraInFrontOfPlayer(playerid, Float:distance, Float:heightoffset) // iPLEOMAX
{
    new Float:P[3];
    GetPlayerPos(playerid, P[0], P[1], P[2]);
    SetPlayerCameraLookAt(playerid, P[0], P[1], P[2]);
    GetXYInFrontOfPlayer(playerid, P[0], P[1], distance);
    SetPlayerCameraPos(playerid, P[0], P[1], P[2]+heightoffset);
}

stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{                                                 // Created by ******
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
pawn Код:
//Example usage:
public OnPlayerSpawn(playerid)
{
    SetPlayerCameraInFrontOfPlayer(playerid, 6, 2);
}
//You can also use Negative distance to set it back of the player.



Re: Camera - Scenario - 05.08.2011

Quote:
Originally Posted by Kush
Посмотреть сообщение
As I know you might be bullshitting, I'll explain. Simply set the floats according to your positions. Easy eh'?
I wasn't bullshitting anything. I don't need your attitude either, so get lost!

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
Are you looking for this? I already made it once..

pawn Код:
stock SetPlayerCameraInFrontOfPlayer(playerid, Float:distance, Float:heightoffset) // iPLEOMAX
{
    new Float:P[3];
    GetPlayerPos(playerid, P[0], P[1], P[2]);
    SetPlayerCameraLookAt(playerid, P[0], P[1], P[2]);
    GetXYInFrontOfPlayer(playerid, P[0], P[1], distance);
    SetPlayerCameraPos(playerid, P[0], P[1], P[2]+heightoffset);
}

stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{                                                 // Created by ******
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
pawn Код:
//Example usage:
public OnPlayerSpawn(playerid)
{
    SetPlayerCameraInFrontOfPlayer(playerid, 6, 2);
}
//You can also use Negative distance to set it back of the player.
Yes, that was exactly what I needed! Thank you!


Re: Camera - iPLEOMAX - 05.08.2011

Your welcome.


Re: Camera - Famalamalam - 05.08.2011

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
Are you looking for this? I already made it once..

pawn Код:
stock SetPlayerCameraInFrontOfPlayer(playerid, Float:distance, Float:heightoffset) // iPLEOMAX
{
    new Float:P[3];
    GetPlayerPos(playerid, P[0], P[1], P[2]);
    SetPlayerCameraLookAt(playerid, P[0], P[1], P[2]);
    GetXYInFrontOfPlayer(playerid, P[0], P[1], distance);
    SetPlayerCameraPos(playerid, P[0], P[1], P[2]+heightoffset);
}

stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{                                                 // Created by ******
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
pawn Код:
//Example usage:
public OnPlayerSpawn(playerid)
{
    SetPlayerCameraInFrontOfPlayer(playerid, 6, 2);
}
//You can also use Negative distance to set it back of the player.
I was going to suggest this way. Getting the XY in front of the player and then flipping the camera around.


Re: Camera - iPLEOMAX - 06.08.2011

Weird, it works for me..

Did you use it like this?

SetPlayerSkin(playerid, ValidateSkin(GetPlayerSkin(playerid)-1, -1) ); //When he presses Prev skin perhaps?
SetPlayerSkin(playerid, ValidateSkin(GetPlayerSkin(playerid)+1, 1) ); //When he presses Next skin..

Btw, You can't use this method for UP/DOWN/LEFT/RIGHT keys:
pawn Код:
if(newkeys == KEY_LEFT)
Try this: GetPlayerKeys