ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setPedLookAt

Function

setPedLookAt

Turns a ped toward the given point and remembers where and for how long it should look. The body turn happens immediately (the ped's heading changes), while the point, time and element are stored for scripts and returned by getPedLookAt; the game does not additionally turn the head. To keep following a target with the eyes use setPedFocus.

Syntax

bool setPedLookAt(ped ped, float x, float y, float z [, int time = 3000, int blend = 1000, element target = nil])

Arguments

pedped
A player or an NPC.
xfloat
X coordinate of the point (or a Vector3 in place of x, y, z).
yfloat
Y coordinate of the point.
zfloat
Z height of the point.
timeint, optional = 3000
How long to look, in milliseconds.
blendint, optional = 1000
Smooth turn time in ms (stored for scripts).Different type in MTA:SA: element target = nil
targetelement, optional = nil
The element the ped looks at (stored for scripts).Not in MTA:SA

Differences from MTA:SA

  • Arguments in a different colour differ from MTA:SA.

In MTA:SA

setPedLookAt(ped thePed, float x, float y, float z, int time = 3000 [, int blend = 1000 ], element target = nil)

Returns

true on success.

Example

local x, y, z = getElementPosition(player)
setPedLookAt(guard, x, y, z, 5000)

See also