The base class for everything that exists in the world on the client.
An Entity is a thin, allocation-cheap wrapper around a game handle: it
stores the integer and nothing else, so constructing one is free and two
wrappers around the same handle are interchangeable. Properties read
through to the natives on every access rather than caching, which is what
you want — the game moves entities constantly.
var vehicle = LocalPlayer.ped().currentVehicle;
if (vehicle != null && vehicle.exists) {
vehicle.coords = vehicle.coords + Vector3.up() * 3.0;
}
Handles are client-local and are recycled by the game. Never store one
across a resource restart, and never send one over the network — send
netId instead, which is stable across clients.
Static methods
staticfromHandle(handle:Int):Entity
Constructor
Variables
write onlyfrozen:Bool
Whether the entity is pinned in place. Write-only — the game exposes no getter.
read onlyhasControl:Bool
Whether this client currently owns the entity. Only the owner may modify a networked entity and have the change replicate.
read onlynetId:Int
The network ID, stable across all clients — the value to send in events. Returns 0 for a purely local entity.
Methods
attachTo(target:Entity, offset:Vector3, rotation:Vector3, bone:Int = 0, collision:Bool = false):Void
Attaches this entity to target, offset from one of its bones.
Parameters:
bone | Bone index on the target; 0 attaches to its origin. |
|---|---|
collision | Whether the two keep colliding with each other. |
delete():Void
Deletes the entity.
Requires ownership: on a networked entity this silently does nothing
unless requestControl() succeeded first.
inlinehasClearLineOfSightTo(other:Entity, flags:Int = 17):Bool
Whether nothing solid sits between this entity and other.
inlineoffsetInWorldCoords(offset:Vector3):Vector3
Converts a position expressed in the entity's own frame into world space.
requestControl(timeoutMs:Int = 1000):Bool
Asks the server for ownership and waits for it, returning whether it
was granted before timeoutMs elapsed.
Every write to a networked entity you don't own is silently reverted by its real owner, so call this first:
if (vehicle.requestControl()) vehicle.repair();
Must be called from inside a coroutine. Ownership can be lost again at any moment, so keep the work that follows short.
inlinesetAsMission(grabFromOtherScript:Bool = true):Void
Claims the entity for this script, so the game's population manager won't clean it up while you're using it.
teleport(position:Vector3, ?heading:Float):Void
Moves the entity without the game's usual "find a valid spot" fixups — no ground snapping, no pushing out of collision. Use it when you have already worked out exactly where the entity belongs.
inlineworldToLocal(worldPosition:Vector3):Vector3
The inverse of offsetInWorldCoords: world space into the entity's frame.