SetPedCameraRotation: Difference between revisions
Jump to navigation
Jump to search
(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)) |
(Explained a little better the function) |
||
Line 1: | Line 1: | ||
__NOTOC__{{Client function}} | __NOTOC__{{Client function}} | ||
{{Note| | {{Note|[[getPedCameraRotation]] may not return the value set by this function. Please refer to [[getPedCameraRotation]] for details.}} | ||
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. | ||
Line 20: | Line 20: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function rotateLocalPlayerCamera() | function rotateLocalPlayerCamera() | ||
--setPedCameraRotation(localPlayer, getPedCameraRotation(localPlayer) + 45) -- | --setPedCameraRotation(localPlayer, getPedCameraRotation(localPlayer) + 45) -- This would work if getPedCameraRotation returned non-transformed angles | ||
setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) + 45)) -- | 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) | outputChatBox("Your camera was rotated 45 degrees counter clockwise.", 0, 255, 0) | ||
end | end |
Revision as of 20:12, 28 October 2014
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) -- 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
- canPedBeKnockedOffBike
- getPedAnalogControlState
- getPedAnimation
- getPedBonePosition
- getPedCameraRotation
- getPedControlState
- getPedMoveState
- getPedOxygenLevel
- getPedSimplestTask
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedVoice
- getPedWeaponMuzzlePosition
- givePedWeapon
- isPedBleeding
- isPedDoingTask
- isPedReloadingWeapon
- isPedTargetingMarkerEnabled
- setAnalogControlState
- setPedAimTarget
- setPedAnalogControlState
- setPedBleeding
- setPedCameraRotation
- setPedCanBeKnockedOffBike
- setPedControlState
- setPedEnterVehicle
- setPedExitVehicle
- IsPedFootBloodEnabled
- setPedFootBloodEnabled
- setPedLookAt
- setPedOxygenLevel
- setPedTargetingMarkerEnabled
- setPedVoice
- Shared
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle