Force Rotate Player Camera

How would I go about rotating the player camera?
I don’t want to rotate the player itself (don’t want to change the headings) just rotate the camera to an angle 90° or 180°

I have no idea how to the get the player/active camera when in freemode.
I tried something along the lines:

local cam = GetRenderingCam()
SetCamRot(cam,  0, 0, 90.0, 2)

Link to native:

Check out the SetGameplayCam* natives.

Thanks for your reply although the only thing those natives appear to be doing is reset my view directly forward or do nothing.

Just noticed. I think the only way around that is to create a camera matching the gameplay camera coords and rotation and set it to your desired rotation angles, attach it to the player, and set it as active.

Something like this would tilt the camera 30 degrees on the y axis.

local gameCamRot = GetGameplayCamRot(0)
local cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", GetEntityCoords(PlayerPedId()), gameCamRot.x, gameCamRot.y + 30, gameCamRot.z, GetGameplayCamFov())
SetCamActive(cam, true)
RenderScriptCams(true, false, 0, true, false)
local offsetCoords = GetOffsetFromEntityGivenWorldCoords(PlayerPedId(), GetGameplayCamCoord())
AttachCamToEntity(cam, PlayerPedId(), offsetCoords, false)

And if you want the player to still control the camera pitch and yaw, here’s a rough workaround I came up with you can add to the above code

Citizen.CreateThread(function ()
    while IsCamActive(cam) do
        local rot = GetGameplayCamRot(0)
        SetCamParams(cam, GetEntityCoords(PlayerPedId()),rot.x, rot.y + 30, rot.z, GetGameplayCamFov())
1 Like

Thanks for your the time you took to make this, I will definitely have to experiment a bit with this to figure out how I can use this properly.