Making the camera move around
#1

Hello guys, today I am asking how to make the camera moves.

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 2323.5830,1283.2872,97.5052);
    SetPlayerFacingAngle(playerid,90);
    SetPlayerCameraPos(playerid, 2313.5503,1283.2721,98.1951);
    SetPlayerCameraLookAt(playerid, 2313.5503,1283.2721,98.1951);
    PlayAudioStreamForPlayer(playerid, "http://racerevolution.cu.cc/music/Skrillex%20-%20First%20of%20the%20Year%20GOAT%20Edition.mp3");
    return 1;
}
How to do it? (Just like 360 rotating)
Reply
#2

There's a new function for camera movi g which would make your life easier.
But you will need to get 4 positions and 1 in the middle total: 5

So on the 4 positions will be left,right,front,back of the rotating object.
The last one in the middle of the rotatin objectA(look at pos)

If u have a reason for not using the camera functions
I have a include made to move the camera for older SAMP versions.
Link: https://sampforum.blast.hk/showthread.php?tid=311638
Reply
#3

Like I'm on the top of pyramid, I need to be around the pyramid, which is down > left > up > right and that's all?

down = 2313.5503,1283.2721,98
left = 2324.3621,1315.3269,98
up = 2348.4209,1283.5682,98
right = 2324.4551,1254.9030,98
Reply
#4

It's stupid to use some static points if you can just calculate the rotation with an angle.

I haven't tested this code, but it should work:
pawn Код:
SetPlayerCameraPosAngle(playerid, Float:x, Float:y, Float:z, Float:a)
{
    SetPlayerCameraPos(playerid, x, y, z);
    SetPlayerCameraLookAt(playerid, x + floatsin(a, degrees), y + floatcos(a, degrees), z);
    return 1;
}

forward SpinCamera(playerid, Float:angle);
public SpinCamera(playerid, Float:angle)
{
    SetPlayerCameraPosAngle(playerid, 2313.5503, 1283.2721, 98.1951, angle);

    SetTimerEx("SpinCamera", 1000, false, "if", playerid, (angle < 360.0) ? (angle + 1.0) : (0.0));
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SpinCamera(playerid, 0.0);
    return 1;
}
Reply
#5

Quote:
Originally Posted by Finn
Посмотреть сообщение
It's stupid to use some static points if you can just calculate the rotation with an angle.

I haven't tested this code, but it should work:
pawn Код:
SetPlayerCameraPosAngle(playerid, Float:x, Float:y, Float:z, Float:a)
{
    SetPlayerCameraPos(playerid, x, y, z);
    SetPlayerCameraLookAt(playerid, x + floatsin(a, degrees), y + floatcos(a, degrees), z);
    return 1;
}

forward SpinCamera(playerid, Float:angle);
public SpinCamera(playerid, Float:angle)
{
    SetPlayerCameraPosAngle(playerid, 2313.5503, 1283.2721, 98.1951, angle);

    SetTimerEx("SpinCamera", 1000, false, "if", playerid, (angle < 360.0) ? (angle + 1.0) : (0.0));
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SpinCamera(playerid, 0.0);
    return 1;
}
It screwed my server up, lol
Reply
#6

Quote:
Originally Posted by LeeXian99
Посмотреть сообщение
It screwed my server up, lol
OK you made me test the code and it worked just fine, here's my mode:

pawn Код:
#include <a_samp>

main()
{
    return 1;
}

public OnGameModeInit()
{
    // AddPlayerClass is a must for a working gamemode, taken from some default script
    AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);
    return 1;
}

SetPlayerCameraPosAngle(playerid, Float:x, Float:y, Float:z, Float:a)
{
    SetPlayerCameraPos(playerid, x, y, z);
    SetPlayerCameraLookAt(playerid, x + floatsin(a, degrees), y + floatcos(a, degrees), z);
    return 1;
}

forward SpinCamera(playerid, Float:angle);
public SpinCamera(playerid, Float:angle)
{
    SetPlayerCameraPosAngle(playerid, 2313.5503, 1283.2721, 98.1951, angle);

    SetTimerEx("SpinCamera", 1000, false, "if", playerid, (angle < 360.0) ? (angle + 1.0) : (0.0));
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SpinCamera(playerid, 0.0);
    return 1;
}
Reply
#7

But the spin camera isn't look at my character... :< Can you please change the look at again so it can spin in front of the characters.

And also it doesn't turn into gaming and continue spinning after spawned.
Reply
#8

this is going to be the leggiest moving camera ;X
Use InterpolateCameraPos
Reply
#9

I might try park's include.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)