Skip to content

AttachZoneToEntity

Lets a zone ride an entity - a moving target, a zone around a cart.

Every tick the zone’s centre is put ox, oy, oz metres from the entity’s position: a prop, an actor, a horse, a cart. nil as the entity leaves the zone where it is. A destroyed entity leaves the zone where it last was.

AttachZoneToEntity(id, entity [, ox, oy, oz])
Parameter Type
id number the zone
entity number | nil the entity; nil detaches the zone
ox number the offset from the entity, metres (0 by default) (optional)
oy number metres (optional)
oz number metres (optional)

boolean - false when there is no such zone or entity

-- a running target: a ball over a horse's back
local horse = CreateHorse(1280, 1120, 26.5, 90)
local target = CreateSphereZone(0, 0, 0, 0.5)
AttachZoneToEntity(target, horse, 0, 0, 1.6)
SetZoneHittable(target, true)

CreateSphereZone · SetZoneHittable · GetZoneInfo · the Zones group of the index