Moving player's camera around a point.
#1

So... I'm making a pool system that includes moving camera around the table but I have two quite big problems with it. First the camera goes to a random point around the table when using the command but it should stay near the player. Second, when I press KEY_LEFT, the camera goes right but it obviously should go left. KEY_RIGHT works fine, though. I think i'm using trigonometric functions wrong. Here are the codes:

pawn Код:
// Command (There's a loop around this code):
TogglePlayerControllable(playerid, false);
new Float:pos[4], Float:camera[2], Float:obj[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetDynamicObjectPos(Piljard[i][pPall][0], obj[0], obj[1], obj[2]);
GetAngleToXY(obj[0], obj[1], pos[0], pos[1], pos[3]);
camera[0] = obj[0] + 1.7 * floatcos(pos[3], degrees);
camera[1] = obj[1] + 1.7 * floatsin(pos[3], degrees);
SetPlayerCameraPos(playerid, camera[0], camera[1], pos[2] + 1);
SetPlayerCameraLookAt(playerid, obj[0], obj[1], Piljard[i][pPos][2] + 1);
SetPlayerPos(playerid, camera[0], camera[1], pos[2]);
SetPlayerFacingAngle(playerid, pos[3]);
ApplyAnimation(playerid,"POOL","POOL_Med_Start",1,0,0,0,1,0,1);
mangibpiljard[playerid] = true;
poolangle[playerid] = pos[3];

// OnPlayerUpdate:
new Float:pos[3], Float:camera[2], Float:obj[3], i = GetClosestFilledPoolTable(playerid), keys[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetDynamicObjectPos(Piljard[i][pPall][0], obj[0], obj[1], obj[2]);
GetPlayerKeys(playerid, keys[0], keys[1], keys[2]);
if (keys[2] == KEY_LEFT) poolangle[playerid]--;
if (keys[2] == KEY_RIGHT) poolangle[playerid]++;
camera[0] = obj[0] + 1.7 * floatcos(poolangle[playerid], degrees);
camera[1] = obj[1] + 1.7 * floatsin(poolangle[playerid], degrees);
SetPlayerCameraPos(playerid, camera[0], camera[1], pos[2] + 1);
SetPlayerCameraLookAt(playerid, obj[0], obj[1], Piljard[i][pPos][2] + 1);
SetPlayerPos(playerid, camera[0], camera[1], pos[2]);
SetPlayerFacingAngle(playerid, poolangle[playerid]);
Thanks!
Reply
#2

ayayay, i am your butterfly
Reply
#3

i need your protection, be my samurai
Reply
#4

lalalalalalala
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)