MobEntity¶
Inherits from: LivingEntity
Represents a mobile entity within the game, inheriting from LivingEntity and adding movement-related attributes and functions.
Fields¶
followingPath: boolean — Read-Only¶
Indicates whether this entity is currently following a path.
Methods¶
startFollowPathTo(target: Vec3, targetRadius: number, searchRange: number, speed: number) → ok: boolean¶
Searches for the shortest path to the given position and moves this entity along the path if one is found.
The followingPath property will be true while the entity is moving and will become false once it reaches the destination or if the path is blocked for too long.
Example
local pig = spell:summon("pig")
local waypoint = pig.pos + Vec3(0, 0, 10)
local ok = pig:startFollowPathTo(waypoint, 0, 100, 1)
if not ok then
error("No path found to waypoint.")
end
while pig.followingPath do
sleep(20)
end
if (waypoint - pig.pos):magnitude() > 1 then
pig:stopFollowPath()
end
Parameters
| Name | Type | Description |
|---|---|---|
target |
Vec3 |
The position to move toward. |
targetRadius |
number |
The distance to maintain from the target position. |
searchRange |
number |
The maximum range to search for a path. |
speed |
number |
The speed at which the entity moves along the path. |
Returns
boolean— oktrueif a path is found and movement starts;falseotherwise.