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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
world |
World |
entity |
Entity |
findNearestTargetOptions |
FindNearestTargetOptions |
Returns
Section titled “Returns”NearestTargetResult | null
Example
Section titled “Example”const nearest = findNearestTarget(world, lamp); if (nearest && nearest.distance < 3) light(lamp);