Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

findNearestTarget

findNearestTarget(world, entity, findNearestTargetOptions?): NearestTargetResult | null

The target nearest entity’s feet, or from, that targets names and accepts passes, as { entity, distance } measured to its feet; null where none is. It never answers entity itself. What a chaser runs at and an NPC turns to. With no targets, a character a player controls now; a layer reaches every character and collider body standing in it.

Parameter Type
world World
entity Entity
findNearestTargetOptions FindNearestTargetOptions

NearestTargetResult | null

const nearest = findNearestTarget(world, lamp); if (nearest && nearest.distance < 3) light(lamp);