SetPedCameraRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Fixed article. This function works but you need use negative value (for example if you want set rot to 100 you need change to -100))
Line 1: Line 1:
__NOTOC__{{Client function}}
__NOTOC__{{Client function}}
{{Note|You need convert the rotation to negative count order to properly rotation, see II example.}}  
{{Note|You need convert the rotation to negative count order to properly rotation, see example.}}  
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.
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.



Revision as of 09:52, 1 August 2014

[[{{{image}}}|link=|]] Note: You need convert the rotation to negative count order to properly rotation, see example.

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.

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

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

Example

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) -- doesn't work properly
    setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) + 45)) -- changes to valid rotation
    outputChatBox("Your camera was rotated 45 degrees counter clockwise.", 0, 255, 0)
end
addCommandHandler("rotatecam", rotateLocalPlayerCamera)

See Also