Doors
Doors agents open, over a Types.DoorDriver your game supplies. Doors.Step is the registration for [Builder:OnStep]:
:OnStep("Door", VluxyAI.Doors.Step())
With no driver it uses [Doors.Attributes]: opening a door sets its VLUXYAI_DOOR/Open attribute to
true, and your door script swings it and sets it back to false when it closes.
VLUXYAI_DOOR/Locked = true makes an agent refuse it and plan around it; VLUXYAI_DOOR/OpenTime is
how many seconds the agent waits for the swing.
For doors that agents never collide with (put the doors and the rigs in collision groups that do not collide), let the agent walk through instead of stopping, open doors it walks up to on a direct line, and let the straight-line check look past them:
:UseDirect(VluxyAI.Pathfinders.Straight.new({
Ignore = VluxyAI.Doors.IgnoreUnlocked(VluxyAI.Pathfinders.Straight.DefaultIgnore),
}))
:OnStep("Door", VluxyAI.Doors.Step(nil, { WalkThrough = true }))
:AddSense(VluxyAI.Doors.Opener())
Then the navmesh modifier alone decides what is passable: PassThrough on while the door is
unlocked, off while it is locked.
Authoring a door for the navmesh: tag the door VLUXYAI_DOOR, give it a PathfindingModifier with
PassThrough on and Label = "Door", and put an invisible, non-colliding part a few studs deep
across the doorway with a modifier labelled "Door", so a waypoint always lands in the doorway.
Navmesh moves the stop to the waypoint before the doorway.
Properties
OPEN_ATTRIBUTE
Doors.OPEN_ATTRIBUTE: "VLUXYAI_DOOR/Open"The attribute Doors.Attributes sets to open a door and reads to see that it is open.
LOCKED_ATTRIBUTE
Doors.LOCKED_ATTRIBUTE: "VLUXYAI_DOOR/Locked"true on a door makes Doors.Attributes report it locked.
OPEN_TIME_ATTRIBUTE
Doors.OPEN_TIME_ATTRIBUTE: "VLUXYAI_DOOR/OpenTime"Seconds the door takes to open, read by Doors.Attributes.
Attributes
Doors.Attributes: DoorDriver
The default driver. Open sets VLUXYAI_DOOR/Open to true; IsOpen reads it; IsLocked reads
VLUXYAI_DOOR/Locked; OpenTime reads VLUXYAI_DOOR/OpenTime when it is a number. Your door script
listens to VLUXYAI_DOOR/Open, and sets it itself when a player opens or closes the door so agents
know.
Functions
Step
Types
interface DoorStepOptions {Tag: string?--
CollectionService tag that finds the door for a navmesh step, which arrives without its Instance. Default "VLUXYAI_DOOR".
Radius: number?--
Studs from the step to look for the tagged door. Default 8.
OpenTime: number?--
Seconds to wait after opening, for a driver with no OpenTime of its own. Default 0.5.
CloseSeconds: number?--
Seconds a locked door is planned around before the agent tries it again. Default 10.
Emit: string?--
Sent with Agent:Emit as a door is opened, the door as the payload, so a client can play a reach. "" sends nothing. Default "Door".
WalkThrough: boolean?--
Open a closed door and keep walking instead of stopping at it, for doors that never collide with agents. Default false.
}The registration for a door label. When the agent reaches the step:
- an open door (or a step with no door found) is walked through without stopping;
-
a locked door is refused: the path fails and the pathfinder plans around that doorway for
CloseSeconds; -
a closed door is opened. By default the agent stops, Agent:Emits
Emit, calls the driver'sOpen, waitsOpenTime, and walks on. WithWalkThroughit opens the door and keeps walking.
Errors
| Type | Description |
|---|---|
| "unknown option" | A key that is not in `DoorStepOptions`. |
| "driver needs IsOpen and Open" |
Opener
Types
interface DoorOpenerOptions {Tag: string?--
CollectionService tag of the doors. Default "VLUXYAI_DOOR".
Radius: number?--
Studs from the agent within which a door ahead is opened. Default 6.
Facing: number?--
How squarely the agent must face the door to open it: the dot product of its look direction and the direction to the door, from -1 (any way) to 1 (dead ahead). Keeps an agent walking past a door in a side wall from opening it. Default 0.3.
Prefix: string?--
Prepended to the keys this sense writes. Default "".
}
A sense for doors the agent walks up to without a labelled step, such as on a direct walk.
Each tick it finds the nearest tagged door within Radius that the agent is facing, writes
it as NearDoor (and NearDoorDistance, math.huge when there is none), and opens it if it
is closed and not locked. Meant for doors agents never collide with; add it with
Builder:AddSense.
Errors
| Type | Description |
|---|---|
| "unknown option" | A key that is not in `DoorOpenerOptions`. |
| "driver needs IsOpen and Open" |
Tick
The Doors.Opener sense's tick: writes NearDoor and NearDoorDistance, and opens that door
when it is closed and unlocked.
Destroy
Doors.Destroy(self: Opener) → ()Nothing to release.
IgnoreUnlocked
An ignore list that also passes through every tagged door the agent could open, so a direct walk treats an unlocked door as the open doorway it is to an agent that never collides with it. Locked doors still block.