Camera
#1

How can I set the players camera to face them?
Reply
#2

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

https://sampwiki.blast.hk/wiki/SetPlayerCameraPos
https://sampwiki.blast.hk/wiki/SetPlayerCameraLookAt
Reply
#3

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

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'?
Reply
#5

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.
Reply
#6

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.
Reply
#7

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!
Reply
#8

Your welcome.
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: