setPedCameraRotation | Multi Theft Auto: Wiki Skip to content

setPedCameraRotation

Client-side
Server-side
Shared

Pair: getPedCameraRotation

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function sets the camera rotation of a ped, e.g. where its camera will look at. Don't confuse this with getCameraMatrix, because that function is designed for fixed (scripted) camera moves.

Note

getPedCameraRotation may not return the value set by this function. Please refer to getPedCameraRotation for details.

OOP Syntax Help! I don't understand this!

  • Method:ped:setCameraRotation(...)
  • Variable: .cameraRotation

Syntax

bool setPedCameraRotation ( ped thePed, float cameraRotation )
Required Arguments
  • thePed: The ped whose camera rotation is to be changed.
  • cameraRotation: The new direction that the ped will walk if you set their forwards control state. If the ped is the local player, it will also change where his camera is looking at if it isn't fixed (i.e. camera target is the local player).

Returns

  • bool: value

Returns true if the camera rotation was changed, false otherwise.

Code Examples

shared

The next code snippet adds a command called /rotatecam, which rotates the camera of the player who uses it.

function rotateLocalPlayerCamera()
--setPedCameraRotation(localPlayer, getPedCameraRotation(localPlayer) + 45) -- This would work if getPedCameraRotation returned non-transformed angles
setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) + 45)) -- Tranform the angle returned and then add 45º to it
outputChatBox("Your camera was rotated 45 degrees counter clockwise.", 0, 255, 0)
end
addCommandHandler("rotatecam", rotateLocalPlayerCamera)

See Also