SetPedLookAt
From Multi Theft Auto: Wiki
Note: Avoid calling setPedLookAt every frame as this can cause bugs like being invincible to burning. |
Note: For remote players, you have to use setPedAimTarget before setPedLookAt. |
Makes a ped turn his head and look at a specific world position or element.
Syntax
bool setPedLookAt ( ped thePed, float x, float y, float z [, int time = 3000 [, int blend = 1000 ], element target = nil ] )
Required Arguments
- thePed: the ped to change the lookat of.
- x: the x coordinate of the world position to look at.
- y: the y coordinate of the world position to look at.
- z: the z coordinate of the world position to look at.
Optional Arguments
- time: the time, in milliseconds, during which the ped will look at the target. Once this time has elapsed, he will look ahead again like before the function was applied. A time of 0 will immediately stop any lookat. A negative time will make the ped look at the target indefinitely.
- blend: the time, in milliseconds, during which the look will blend.
- target: if this argument is specified, the position arguments will be ignored and the ped's gaze will follow the specified element instead. Can be a player, a vehicle, another ped etc.
Example
This example makes the local player look at where the camera points at. If you want to sync this effect with other players you can use triggerLatentServerEvent and triggerLatentClientEvent functions.
local screenSize_X, screenSize_Y = guiGetScreenSize() function pedLookAt() local x, y, z = getWorldFromScreenPosition(screenSize_X / 2, screenSize_Y / 2, 15) setPedLookAt(localPlayer, x, y, z, -1, 0) end setTimer(pedLookAt, 120, 0)
Issues
Issue ID | Description |
---|---|
#4325 | setPedLookAt does not work for remote players |
See Also
- getPedAmmoInClip
- getPedAnalogControlState
- getPedAnimation
- getPedArmor
- getPedBonePosition
- getPedCameraRotation
- getPedClothes
- getPedContactElement
- getPedControlState
- getPedFightingStyle
- getPedMoveState
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedOxygenLevel
- getPedSimplestTask
- getPedStat
- getPedTarget
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedTotalAmmo
- getPedVoice
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponMuzzlePosition
- getPedWeaponSlot
- getValidPedModels
- givePedWeapon
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDoingTask
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedClothes
- removePedFromVehicle
- setAnalogControlState
- setPedAimTarget
- setPedAnalogControlState
- setPedAnimation
- setPedAnimationProgress
FROM VERSION 1.5.7 r19626 ONWARDS
FROM VERSION 1.5.7 r19626 ONWARDS
- setPedFootBloodEnabled
- setPedHeadless
- setPedLookAt
- setPedOnFire
- setPedOxygenLevel
- setPedStat
- setPedTargetingMarkerEnabled
- setPedVoice
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle