Class Navigator
- Namespace
- Trailblazer.Navigation
- Assembly
- Trailblazer.dll
Base class for an object that owns movement, traversal state, and simulation flow.
public abstract class Navigator : INavigate, ISteer, IVoxelOccupant, IRecordable
- Inheritance
-
Navigator
- Implements
-
IVoxelOccupantIRecordable
- Inherited Members
Remarks
This class acts as a bridge between the simulation logic and the entity's external representation. It defines common traversal behaviors and lifecycle methods that can be extended by concrete implementations.
Constructors
Navigator()
Initializes a new unbound navigator. Bind it to a context before setup.
protected Navigator()
Navigator(TrailblazerWorldContext)
Initializes a new navigator bound to the supplied world context.
protected Navigator(TrailblazerWorldContext context)
Parameters
contextTrailblazerWorldContext
Fields
_acceleration
The current acceleration vector of the object, updated each frame based on velocity change.
protected Vector3d _acceleration
Field Value
- Vector3d
_frameCondition
Represents the traversal state of a scout, including its movement medium and surface interactions.
protected TrekCondition _frameCondition
Field Value
_frameRequest
Represents a movement request for a object to pass to NavMotor, containing the current origin, foot position, rotation, direction, speed, and frame-owned locomotion intent.
protected TrekRequest _frameRequest
Field Value
_globalId
Stable runtime identity used for occupancy and steering coordination.
protected Guid _globalId
Field Value
Remarks
By default this is allocated deterministically from object setup order. Hosts can override it during setup when a broader simulation stack already owns stable agent ids.
_isInitialized
Indicates whether the Navigator has been initialized.
protected bool _isInitialized
Field Value
_isSet
Indicates whether the Navigator has been set.
protected bool _isSet
Field Value
_lastPosition
The last world position of the object.
protected Vector3d _lastPosition
Field Value
- Vector3d
_motor
The controller responsible for managing the object's movement and physics interactions.
protected NavMotor? _motor
Field Value
_position
The absolute world-space position of the occupant, representing its precise location in the environment.
protected Vector3d _position
Field Value
- Vector3d
_positionDelta
The change in position to apply during the current simulation frame.
protected Vector3d _positionDelta
Field Value
- Vector3d
_rotation
The object's visual rotation in world space.
protected FixedQuaternion _rotation
Field Value
- FixedQuaternion
_rotationDelta
The change in rotation to apply during the current simulation frame.
protected FixedQuaternion _rotationDelta
Field Value
- FixedQuaternion
_speed
The current movement speed, derived from the magnitude of the velocity.
protected Fixed64 _speed
Field Value
- Fixed64
_steering
The controller responsible for managing the object's desired movement direction.
protected NavSteering? _steering
Field Value
_turning
The controller responsible for managing the object's rotation towards the movement direction.
protected NavTurning? _turning
Field Value
_velocity
The current velocity of the object in world space.
protected Vector3d _velocity
Field Value
- Vector3d
_velocityDelta
The velocity change computed during the simulation frame.
protected Vector3d _velocityDelta
Field Value
- Vector3d
Properties
Acceleration
The current acceleration vector of the object, updated each frame based on velocity change.
public Vector3d Acceleration { get; }
Property Value
- Vector3d
BodyShape
Gets the authoritative body shape from NavigationProfile.
public KinematicBodyShape BodyShape { get; }
Property Value
Context
Gets the world context this navigator is bound to.
public TrailblazerWorldContext? Context { get; }
Property Value
FootPosition
Gets the derived world-space foot point used by navigation and locomotion.
public Vector3d FootPosition { get; }
Property Value
- Vector3d
Forward
The direction the object is currently facing.
public Vector3d Forward { get; protected set; }
Property Value
- Vector3d
GlobalId
Stable runtime identity used for occupancy and steering coordination.
public Guid GlobalId { get; }
Property Value
Remarks
By default this is allocated deterministically from object setup order. Hosts can override it during setup when a broader simulation stack already owns stable agent ids.
HeightmapGrounding
Gets the opt-in heightmap grounding settings owned by this navigator.
public NavigatorHeightmapGroundingSettings HeightmapGrounding { get; }
Property Value
IsActive
Indicates whether the Navigator is currently active and ready for simulation.
public bool IsActive { get; }
Property Value
IsGuided
Indicates whether the current traversal session owns navigation guidance.
public bool IsGuided { get; }
Property Value
IsLockedOn
Gets or sets a value indicating whether the object is currently locked on to a target.
public bool IsLockedOn { get; set; }
Property Value
LastCommittedCell
Gets the effective navigation cell resolved after the latest motion commit.
public NavigationCommittedCellState? LastCommittedCell { get; }
Property Value
LastPosition
The last world position of the object.
public Vector3d LastPosition { get; }
Property Value
- Vector3d
Motor
The controller responsible for managing the object's movement and physics interactions.
public NavMotor? Motor { get; }
Property Value
NavigationProfile
Gets the exact immutable navigation profile supplied during setup.
public NavigationAgentProfile NavigationProfile { get; }
Property Value
OccupantGroupId
The group Id used for grouping occupants within a scan cell. Occupants with the same group Id belong to the same logical group. This allows efficient retrieval of related occupants in spatial queries.
public byte OccupantGroupId { get; set; }
Property Value
PendingTransition
Gets the exact transition action currently awaiting host completion.
public NavigationTransitionInstruction? PendingTransition { get; }
Property Value
Position
The absolute world-space position of the occupant, representing its precise location in the environment.
public Vector3d Position { get; }
Property Value
- Vector3d
Radius
Body radius used for spatial checks.
public Fixed64 Radius { get; }
Property Value
- Fixed64
Rotation
The object's visual rotation in world space.
public FixedQuaternion Rotation { get; }
Property Value
- FixedQuaternion
Speed
The current movement speed, derived from the magnitude of the velocity.
public Fixed64 Speed { get; }
Property Value
- Fixed64
Steering
The controller responsible for managing the object's desired movement direction.
public NavSteering? Steering { get; }
Property Value
StuckThresholdSpeed
Minimum velocity threshold used to determine if the object is considered stuck.
public Fixed64 StuckThresholdSpeed { get; }
Property Value
- Fixed64
Turning
The controller responsible for managing the object's rotation towards the movement direction.
public NavTurning? Turning { get; }
Property Value
Velocity
The current velocity of the object in world space.
public Vector3d Velocity { get; }
Property Value
- Vector3d
Methods
Activate(TrekCondition, Vector3d, NavigationAgentProfile, FixedQuaternion?, Vector3d?, Guid?)
Initializes and activates the object with the specified condition, position, and optional parameters.
public virtual void Activate(TrekCondition condition, Vector3d position, NavigationAgentProfile navigationProfile, FixedQuaternion? rotation = null, Vector3d? velocity = null, Guid? globalId = null)
Parameters
conditionTrekConditionThe condition that determines how the object is initialized and activated.
positionVector3dThe position in world coordinates where the object will be placed.
navigationProfileNavigationAgentProfileThe exact body geometry and traversal capabilities owned by the object.
rotationFixedQuaternion?The optional rotation to apply to the object. If null, a default rotation is used.
velocityVector3d?The optional initial velocity of the object. If null, the object is initialized with zero velocity.
globalIdGuid?The optional global identifier for the object. If null, a new identifier may be generated.
Activate(TrailblazerWorldContext, TrekCondition, Vector3d, NavigationAgentProfile, FixedQuaternion?, Vector3d?, Guid?)
Initializes and activates the object with the specified condition, position, and optional parameters.
public virtual void Activate(TrailblazerWorldContext context, TrekCondition condition, Vector3d position, NavigationAgentProfile navigationProfile, FixedQuaternion? rotation = null, Vector3d? velocity = null, Guid? globalId = null)
Parameters
contextTrailblazerWorldContextThe world context that owns this navigator.
conditionTrekConditionThe condition that determines how the object is initialized and activated.
positionVector3dThe position in world coordinates where the object will be placed.
navigationProfileNavigationAgentProfileThe exact body geometry and traversal capabilities owned by the object.
rotationFixedQuaternion?The optional rotation to apply to the object. If null, a default rotation is used.
velocityVector3d?The optional initial velocity of the object. If null, the object is initialized with zero velocity.
globalIdGuid?The optional global identifier for the object. If null, a new identifier may be generated.
AddPositionDelta(Vector3d)
Applies a positional delta to the current position and updates the last known position accordingly.
public virtual void AddPositionDelta(Vector3d delta)
Parameters
deltaVector3dThe vector representing the positional change to apply. If the vector is FixedMathSharp.Vector3d.Zero, no change is made.
Remarks
This method adjusts both the current and last positions to maintain consistent velocity calculations. Use this method to apply external position changes without affecting velocity tracking.
AddVelocityDelta(Vector3d)
Adds the specified velocity change to the current velocity delta.
public virtual void AddVelocityDelta(Vector3d delta)
Parameters
deltaVector3dThe velocity change to add. If this value is FixedMathSharp.Vector3d.Zero, no change is applied.
ApplyGuidedTrekRequest(PathQuery, TrekRate?, bool?, bool?, bool?, bool?, bool, int)
Applies complete immutable graph-backed A* or flow-field intent.
public virtual void ApplyGuidedTrekRequest(PathQuery query, TrekRate? rate = null, bool? isRequestingFlight = null, bool? isRequestingSwim = null, bool? isRequestingClimb = null, bool? isRequestingJump = null, bool canAffordJump = true, int groupId = -1)
Parameters
queryPathQueryThe exact query intent whose start point equals the current derived foot position.
rateTrekRate?Desired movement rate.
isRequestingFlightbool?Whether the object intends to fly or glide during traversal.
isRequestingSwimbool?Whether the object intends to actively swim during traversal.
isRequestingClimbbool?Whether the object explicitly intends to climb during traversal.
isRequestingJumpbool?Whether the object intends to jump during traversal.
canAffordJumpboolFrame-owned jump affordability answer for this request.
groupIdintOptional shared movement-group identifier.
Exceptions
- ArgumentException
Thrown when the query does not match the Navigator's exact navigation profile.
ApplyInputTrekRequest(Vector3d?, TrekRate?, Vector3d?, bool?, bool?, bool?, bool?, bool)
Constructs and applies a traversal request using high-level navigation input values.
public virtual void ApplyInputTrekRequest(Vector3d? direction = null, TrekRate? rate = null, Vector3d? facingDirection = null, bool? isRequestingFlight = null, bool? isRequestingSwim = null, bool? isRequestingClimb = null, bool? isRequestingJump = null, bool canAffordJump = true)
Parameters
directionVector3d?Desired direction of travel.
rateTrekRate?Rate of travel (walk, run, etc.).
facingDirectionVector3d?Optional world-space facing direction to use instead of facing along the movement direction.
isRequestingFlightbool?Whether the agent is requesting to fly or glide.
isRequestingSwimbool?Whether the agent is requesting active swim control while in liquid.
isRequestingClimbbool?Whether the agent is requesting to climb or maintain climb intent.
isRequestingJumpbool?Whether the agent is requesting a jump action.
canAffordJumpboolFrame-owned jump affordability answer for this request.
ApplyRotationDelta(FixedQuaternion)
Applies the specified rotation delta to the current rotation state.
public virtual void ApplyRotationDelta(FixedQuaternion delta)
Parameters
deltaFixedQuaternionThe rotation delta to apply. Must not be FixedMathSharp.FixedQuaternion.Identity; otherwise, no change is made.
BindContext(TrailblazerWorldContext)
Binds this navigator to a world context before setup.
public virtual void BindContext(TrailblazerWorldContext context)
Parameters
contextTrailblazerWorldContext
CheckTrekCondition()
Checks and updates the current traversal condition.
public abstract void CheckTrekCondition()
CheckVoxelOccupancy(bool)
Checks and updates the occupancy status of the current and previous voxels based on the object's position.
protected virtual void CheckVoxelOccupancy(bool init = false)
Parameters
initboolIndicates whether the occupancy check is being performed during initialization. If set to true, the check is performed regardless of position changes.
Remarks
This method ensures that the object is registered as an occupant in the correct voxel and removed from the previous voxel if the position has changed. It should be called whenever the object's position may have changed to maintain accurate occupancy tracking.
CommitFrameMotion()
Finalizes traversal by updating movement calculations and applying corrections.
public virtual void CommitFrameMotion()
Remarks
Should be called once every rendering/player interfacing frame, after physics bodies apply velocity changes.
CompletePendingTransition(in NavigationTransitionInstruction)
Completes the exact pending semantic action owned by the active guide.
public virtual NavigationGuideStatus CompletePendingTransition(in NavigationTransitionInstruction instruction)
Parameters
instructionNavigationTransitionInstruction
Returns
ConfigureHeightmapGrounding(HeightmapGroundingMode, string?, Fixed64?, Fixed64?)
Configures explicit heightmap grounding for concrete navigators that opt in during traversal checks.
public virtual void ConfigureHeightmapGrounding(HeightmapGroundingMode mode, string? layerName = null, Fixed64? groundOffset = null, Fixed64? snapTolerance = null)
Parameters
modeHeightmapGroundingModeHeightmap grounding behavior to use when TryApplyHeightmapGrounding(bool, Fixed64?, MotionTransfer) is called.
layerNamestringOptional initial layer preference used before an active layer is established.
groundOffsetFixed64?Optional extra root offset above the sampled ground Y.
snapToleranceFixed64?Optional maximum root-Y correction allowed for positional projection.
CreateLocomotionProfile()
Creates the locomotion profile used when this object initializes its motor.
protected virtual LocomotionProfile CreateLocomotionProfile()
Returns
Remarks
Override this to install a smaller or custom locomotion set per object type while preserving the default profile for callers that do not opt in.
GenerateGUID()
Generates a new globally unique identifier (GUID) for use in object identification or tracking.
protected virtual Guid GenerateGUID()
Returns
Remarks
Override this method to customize GUID generation logic if a different strategy is required by derived classes.
Initialize(TrekCondition)
Initializes the object by setting up its defaults, events, traversal state, and movement controller.
public virtual void Initialize(TrekCondition condition)
Parameters
conditionTrekCondition
NotifyCollision()
Notifies the object that a collision occurred so collision-driven subsystem responses can run on the next simulation step.
public virtual void NotifyCollision()
PrewarmMovementGroup()
Prewarms the steering movement-group coordinator from this object's currently loaded state.
public virtual void PrewarmMovementGroup()
Remarks
This is primarily useful after loading several grouped navigators through Chronicler. Call it once for each loaded object before the next simulation frame if you want movement-group formation state available immediately. If it is skipped, grouped steering will still rejoin lazily on the next update.
RecordData(IChronicler)
Records the current instance state to the provided chronicler.
public virtual void RecordData(IChronicler chronicler)
Parameters
chroniclerIChroniclerThe active chronicler pass.
ReplaceTrekCondition(TrekCondition, bool)
Replaces the current traversal state with the given one.
public virtual void ReplaceTrekCondition(TrekCondition state, bool updateMotorState)
Parameters
stateTrekConditionThe new traversal condition to apply.
updateMotorStateboolFlags whether or not to immediately sync the new traversal snapshot into the motor before the next traversal step.
Reset()
Resets the state of the object to its initial configuration, clearing any active conditions, requests, and internal flags.
public virtual void Reset()
Remarks
Call this method to reinitialize the object for reuse or to clear any ongoing operations. After calling this method, the object will be in the same state as after construction, and any previous state or intent will be lost. This method is intended to be overridden in derived classes to extend the reset behavior as needed.
SetAirborne(Fixed64?, GroundCondition?, Fixed64?, bool)
Updates the object to an airborne state while preserving the last known ground condition unless an override is provided.
public virtual void SetAirborne(Fixed64? surfaceLevel = null, GroundCondition? launchCondition = null, Fixed64? ceilingLevel = null, bool updateMotorState = false)
Parameters
surfaceLevelFixed64?launchConditionGroundCondition?ceilingLevelFixed64?updateMotorStatebool
SetFrameJumpAffordability(bool)
Sets the frame-owned jump affordability snapshot used by NavMotor on the next traversal step.
public virtual void SetFrameJumpAffordability(bool canAffordJump)
Parameters
canAffordJumpbool
SetGroundContact(Fixed64, PlatformSnapshot, Fixed64?, MotionTransfer, Fixed64?, bool)
Updates the object to a grounded state using a host-provided platform snapshot plus surface settings. Inert snapshots still describe the contacted surface but opt out of moving-platform carry logic.
public virtual void SetGroundContact(Fixed64 surfaceLevel, PlatformSnapshot platform = default, Fixed64? surfaceFriction = null, MotionTransfer motionTransfer = MotionTransfer.None, Fixed64? ceilingLevel = null, bool updateMotorState = false)
Parameters
surfaceLevelFixed64platformPlatformSnapshotsurfaceFrictionFixed64?motionTransferMotionTransferceilingLevelFixed64?updateMotorStatebool
SetGuidedTrekRate(TrekRate)
Changes the speed at which the object is currently traveling without altering direction.
public virtual void SetGuidedTrekRate(TrekRate rate)
Parameters
rateTrekRateNew traversal rate to apply (walk, run, etc.).
SetTrekCondition(TraversalMedium?, Fixed64?, GroundCondition?, bool, Fixed64?, bool)
Updates the scout’s traversal state, including its current medium and surface information.
public virtual void SetTrekCondition(TraversalMedium? medium = null, Fixed64? surfaceLevel = null, GroundCondition? surfaceCondition = null, bool replaceGroundContact = true, Fixed64? ceilingLevel = null, bool updateMotorState = false)
Parameters
mediumTraversalMedium?The traversal medium (e.g., ground, air, water).
surfaceLevelFixed64?The vertical surface level, if applicable.
surfaceConditionGroundCondition?The ground state data, if applicable.
replaceGroundContactboolWhether to replace the current ground contact platform. This should be true when entering water or jumping off a platform, but false when maintaining contact with the same surface across frames.
ceilingLevelFixed64?The vertical ceiling level, if applicable.
updateMotorStateboolFlags whether or not to update the motor's internal surface state. Otherwise, it should be updated at the end of the frame.
Remarks
Make sure to update this before the next CommitFrameMotion() so FinalizeTraversal(Vector3d, Vector3d, FixedQuaternion, TrekCondition, Vector3d?) can update its state.
If the motor must see the new snapshot before the next Simulate(), either pass
updateMotorState as true or call SyncCurrentTrekConditionToMotor().
SetWaterContact(Fixed64, Fixed64?, bool)
Updates the object to a water-contact state and clears any grounded platform contact.
public virtual void SetWaterContact(Fixed64 surfaceLevel, Fixed64? ceilingLevel = null, bool updateMotorState = false)
Parameters
surfaceLevelFixed64ceilingLevelFixed64?updateMotorStatebool
Setup(Vector3d, NavigationAgentProfile, FixedQuaternion?, Vector3d?, Guid?)
Sets the initial position, exact navigation profile, rotation, velocity, and optional stable identity.
public virtual void Setup(Vector3d position, NavigationAgentProfile navigationProfile, FixedQuaternion? rotation = null, Vector3d? velocity = null, Guid? globalId = null)
Parameters
positionVector3dInitial world-space position.
navigationProfileNavigationAgentProfileThe exact body geometry and traversal capabilities owned by the object.
rotationFixedQuaternion?Optional starting rotation.
velocityVector3d?Optional initial velocity.
globalIdGuid?Optional host-provided stable identity. When omitted, Trailblazer assigns one deterministically from setup order.
Setup(TrailblazerWorldContext, Vector3d, NavigationAgentProfile, FixedQuaternion?, Vector3d?, Guid?)
Sets the initial position, exact navigation profile, rotation, velocity, and optional stable identity.
public virtual void Setup(TrailblazerWorldContext context, Vector3d position, NavigationAgentProfile navigationProfile, FixedQuaternion? rotation = null, Vector3d? velocity = null, Guid? globalId = null)
Parameters
contextTrailblazerWorldContextThe world context that owns this navigator.
positionVector3dInitial world-space position.
navigationProfileNavigationAgentProfileThe exact body geometry and traversal capabilities owned by the object.
rotationFixedQuaternion?Optional starting rotation.
velocityVector3d?Optional initial velocity.
globalIdGuid?Optional host-provided stable identity. When omitted, Trailblazer assigns one deterministically from setup order.
Simulate()
Runs simulation logic for this object (input handling, steering, etc.).
public virtual void Simulate()
SyncCurrentTrekConditionToMotor()
Pushes the current traversal snapshot into the motor before the next traversal phase begins.
public virtual void SyncCurrentTrekConditionToMotor()
ToggleGuidedClimb(bool)
Called to toggle climb intent if supported by the installed locomotion profile.
public virtual void ToggleGuidedClimb(bool status)
Parameters
statusbool
ToggleGuidedFlight(bool)
Called to toggle controlled flight if supported by the installed locomotion profile.
public virtual void ToggleGuidedFlight(bool status)
Parameters
statusbool
ToggleGuidedJump(bool)
Called to make the agent jump if allowed and in a valid state.
public virtual void ToggleGuidedJump(bool status)
Parameters
statusbool
ToggleGuidedSwim(bool)
Called to toggle active swim control if supported by the installed locomotion profile.
public virtual void ToggleGuidedSwim(bool status)
Parameters
statusbool
TryApplyHeightmapGrounding(bool, Fixed64?, MotionTransfer)
Applies configured heightmap grounding when a concrete navigator chooses to opt in.
protected bool TryApplyHeightmapGrounding(bool updateMotorState = false, Fixed64? surfaceFriction = null, MotionTransfer motionTransfer = MotionTransfer.None)
Parameters
updateMotorStateboolWhether to immediately sync the resulting ground contact into the motor.
surfaceFrictionFixed64?Optional friction stored in the generated ground condition.
motionTransferMotionTransferMotion transfer mode stored in the generated ground condition.
Returns
- bool
True when a registered heightmap sample updated this navigator's ground contact.
Remarks
The base navigator never calls this automatically. Host/concrete navigators should invoke it from their traversal probing code after they know the navigator is grounded on solid terrain.
TryGetTurnDirection(TrekRequest, out Vector3d)
Attempts to resolve the direction the object should try to face for the current frame.
protected virtual bool TryGetTurnDirection(TrekRequest request, out Vector3d turnDirection)
Parameters
requestTrekRequestturnDirectionVector3d
Returns
Events
CommittedCellChanged
Occurs after committed motion enters a different effective cell or leaves navigation data.
public event Action<NavigationCommittedCellState?>? CommittedCellChanged