SA-MP Forums Archive
InterpolateCamera help - 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)
+--- Thread: InterpolateCamera help (/showthread.php?tid=636181)



InterpolateCamera help - SteeLFelna - 21.06.2017

Hi, I'm interested in how to do next.

To get current player camera look and set at first x, y ,z for InterpolateCamera. And how to get body part x,y,z, to look at player's back, like this:



A camera with a current view just to approach to the player.


Re: InterpolateCamera help - TEKNOJIHAD1 - 21.06.2017

I didn't test it but your code should look like this. You might have to change a thing or two.

PHP код:
new Float:PlayerX;
new 
Float:PlayerY;
new 
Float:PlayerZ;
new const 
Float:DISTANCE 2.0;
new 
Float:angle;
GetPlayerPos(playeridPlayerXPlayerYPlayerZ);
GetPlayerFacingAngle(playeridAngle);
SetCameraBehindPlayer(playerid);
angle angle+180.0;
new 
Float:F_FLOATSIN floatsin(-angledegrees);
new 
Float:F_FLOATCOS floatcos(-angledegrees);
TogglePlayerSpectating(playerid1);
InterpolateCameraPos(playeridPlayerXPlayerYPlayerZF_FLOATSINF_FLOATCOSPlayerZ2000CAMERA_MOVE); 



Re: InterpolateCamera help - SteeLFelna - 21.06.2017

Not working, I tried to change some things, but not with success..
Camera going to this coordinates:




Re: InterpolateCamera help - TEKNOJIHAD1 - 21.06.2017

Actually, I'm not sure if you can take control of the player's camera without him being on Spectate mode or frozen.
You can remove "TogglePlayerSpectating" and replace it with "TogglePlayerControllable(playerid, 0); And use "SetPlayerCameraPos" instead of "InterpolateCameraPos" but it won't be smooth like the interpolate one.


Re: InterpolateCamera help - SteeLFelna - 21.06.2017

You don't understand me.

I want this.. let's me explain..



Start of interpolate camera must be on current camera look, to like from camera direct interpolate to front of player.


Re: InterpolateCamera help - JasonRiggs - 22.06.2017

You want it like to make it a class selection? If you want that, Set the player spectate mode on, player controllable off, set the camera pos, Set the Camera look at that's all.


Re: InterpolateCamera help - SteeLFelna - 26.06.2017

I want to get coordinates from front of player face, and modify camera to look like this:




Re: InterpolateCamera help - NaS - 26.06.2017

First use TogglePlayerControllable to freeze the player.

Then get the coords and the angle:

Код:
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
Then calculate the position in front of him (replace distance with the distance obviously):

Код:
new Float:camx = distance * floatsin(-a, degrees), Float:camy = distance * floatcos(-a, degrees);
After that set the camera pos to the camx, camy (and z from player position) values and the camera to look at the original Player Position.

Spectate Mode is unneccessary plus it will make it impossible to see your own character.


If you want the character to be a bit more on the right or left of the screen, you can calculate a small offset for the x/y Player Position (similar to how the cam x/y was calculated) to make the camera look at the side of the character.

If you want the cam to be smoothly positioning itself just use CAMERA_MOVE in SetPlayerCameraLookAt.