Keep Camera Angle
#1

Good, this time I'm doing a system of Dashcams for vehicles but I have a small problem, I create an object in the position of the hood, just so that it looks good and I use an AttachCameraToObject so that the camera is always in that object but at the moment The car turns the camera is in the same angle leaving the car on one side of the hood and not facing as it starts, at first it looks good but it is when you turn the car that starts to see sideways.

Code that I am using.

Код:
GetVehicleZAngle(953,vAng);
SetPlayerFacingAngle(playerid, vAng);
SetCameraBehindPlayer(playerid);
PlayerSpectateVehicle(playerid, 953);
ObjetoCamaraVeh[playerid] = CreateObject(19300, 0, 0, 0, 0, 0, 0 );
AttachObjectToVehicle(ObjetoCamaraVeh[playerid], 953, 0, 1, 0.5, 0, 0, 0 );
AttachCameraToObject(playerid, ObjetoCamaraVeh[playerid]);
Reply
#2

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

Use this function in a timer to set the camera's lookat every second

For the x and y parameters , use the getxyinfrontofplayer function
And set the angle to the vehicle's z angle
Reply
#3

It's not possible to influence the camera angle while it is attached. Any Camera functions will detach the camera, TogglePlayerControllable seems the only way to freeze it but the camera will be locked at a specific angle, facing somewhere up (useless).

You can however work with the different spectate modes. Mode 3 fixes the Camera in the direction the vehicle is facing and lets you also set the look at position. But the problem is that you cannot drive yourself while having the cam activated...

So it's not really possible to create a fixed dashcam while driving the vehicle, but something similar if you are spectator.

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/SetPlayerCameraLookAt

Use this function in a timer to set the camera's lookat every second

For the x and y parameters , use the getxyinfrontofplayer function
And set the angle to the vehicle's z angle
That will detach the camera and place it at the last position it was at before attaching it.
Reply
#4

@NaS

Isn't there any other solution like
Detaching and re attaching the cam in a repeated timer?
Reply
#5

This would be a spectator mode since the cameras will be monitored from the LSPD control center, how could it be done to always fix the camera in the direction the vehicle will go, with the player using the PlayerSpectateVehicle function?
Reply
#6

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
@NaS

Isn't there any other solution like
Detaching and re attaching the cam in a repeated timer?
Sorry you were right. Just tried around and it does indeed work. Set the angle first like you suggested, then re-attach it again.

Quote:
Originally Posted by Romero837
Посмотреть сообщение
This would be a spectator mode since the cameras will be monitored from the LSPD control center, how could it be done to always fix the camera in the direction the vehicle will go, with the player using the PlayerSpectateVehicle function?
Try like David suggested, attach an Object to the vehicle and then repeatedly update the Camera and attach it to the Object again in a timer.
No need for PlayerSpectateVehicle here (only TogglePlayerSpectating).

If you want to try the PlayerSpectateVehicle method, you only have to call PlayerSpectateVehicle with mode 3. But the camera position is different for many cars. It'll be smoother than the Camera Attaching method though.

You can also combine those two! First use PlayerSpectateVehicle, and then attach the Camera to an Object, which is attached to the Vehicle. This will prevent the Camera from being rotated while at the same time maintaining the direction the vehicle is looking (smoothly). Seems a bit buggy though. It sometimes warps the position and stops the cam from being attached.. So maybe you need to re-attach it regularly or so. Guess the attaching and the mode aren't working too well together.
Reply
#7

I did not use the idea of ​​the timer because it causes lag and ends up crashing the player since I would have to execute it many times for the angle to update correctly, finally it occurred to me to leave the camera fixed but that can be moved with the movement of the mouse , An example is when we use the EditAttachedObject function and press the space key, the mouse disappears but you can move it anywhere to move the camera.


Reply
#8

Any thinks?
Reply
#9

Quote:
Originally Posted by Romero837
Посмотреть сообщение
Any thinks?
Only thing left is the spectate mode, I think EditAttachedObject won't get you far here. But there's not much more than that I guess.
Reply
#10

Quote:
Originally Posted by NaS
Посмотреть сообщение
Only thing left is the spectate mode, I think EditAttachedObject won't get you far here. But there's not much more than that I guess.
Thank you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)