Signal3
Signal support.
NavigationAgent3D.swift:2357class Signal3
Use the connect(flags:_:)
method to connect to the signal on the container object, and disconnect(_:)
to drop the connection.
You can also await the emitted
property for waiting for a single emission of the signal.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (57) members.
Types
class Signal1
Signal support.
class Signal2
Signal support.
Type members
Instance members
var avoidanceEnabled: Bool
If
true
the agent is registered for an RVO avoidance callback on theNavigationServer3D
. Whenvelocity
is set and the processing is completed asafe_velocity
Vector3 is received with a signal connection to [signal velocity_computed]. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.var avoidanceLayers: UInt32
A bitfield determining the avoidance layers for this NavigationAgent. Other agents with a matching bit on the
avoidanceMask
will avoid this agent.var avoidanceMask: UInt32
A bitfield determining what other avoidance agents and obstacles this NavigationAgent will avoid when a bit matches at least one of their
avoidanceLayers
.var avoidancePriority: Double
The agent does not adjust the velocity for other agents that would match the
avoidanceMask
but have a loweravoidancePriority
. This in turn makes the other agents with lower priority adjust their velocities even more to avoid collision with this agent.var debugEnabled: Bool
If
true
shows debug visuals for this agent.var debugPathCustomColor: Color
If
debugUseCustom
istrue
uses this color for this agent instead of global color.var debugPathCustomPointSize: Double
If
debugUseCustom
istrue
uses this rasterized point size for rendering path points for this agent instead of global point size.var debugUseCustom: Bool
If
true
uses the defineddebugPathCustomColor
for this agent instead of global color.var height: Double
The height of the avoidance agent. Agents will ignore other agents or obstacles that are above or below their current position + height in 2D avoidance. Does nothing in 3D avoidance which uses radius spheres alone.
var keepYVelocity: Bool
If
true
, and the agent uses 2D avoidance, it will remember the set y-axis velocity and reapply it after the avoidance step. While 2D avoidance has no y-axis and simulates on a flat plane this setting can help to soften the most obvious clipping on uneven 3D geometry.var linkReached: Signal2
Signals that the agent reached a navigation link. Emitted when the agent moves within
pathDesiredDistance
of the next position of the path when that position is a navigation link.var maxNeighbors: Int32
The maximum number of neighbors for the agent to consider.
var maxSpeed: Double
The maximum speed that an agent can move.
var navigationFinished: SimpleSignal
Signals that the agent’s navigation has finished. If the target is reachable, navigation ends when the target is reached. If the target is unreachable, navigation ends when the last waypoint of the path is reached. This signal is emitted only once per loaded path.
var navigationLayers: UInt32
A bitfield determining which navigation layers of navigation regions this agent will use to calculate a path. Changing it during runtime will clear the current navigation path and generate a new one, according to the new navigation layers.
var neighborDistance: Double
The distance to search for other agents.
var pathChanged: SimpleSignal
Emitted when the agent had to update the loaded path:
var pathDesiredDistance: Double
The distance threshold before a path point is considered to be reached. This allows agents to not have to hit a path point on the path exactly, but only to reach its general area. If this value is set too high, the NavigationAgent will skip points on the path, which can lead to it leaving the navigation mesh. If this value is set too low, the NavigationAgent will be stuck in a repath loop because it will constantly overshoot the distance to the next point on each physics frame update.
var pathHeightOffset: Double
The height offset is subtracted from the y-axis value of any vector path position for this NavigationAgent. The NavigationAgent height offset does not change or influence the navigation mesh or pathfinding query result. Additional navigation maps that use regions with navigation meshes that the developer baked with appropriate agent radius or height values are required to support different-sized agents.
var pathMaxDistance: Double
The maximum distance the agent is allowed away from the ideal path to the final position. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
var pathMetadataFlags: NavigationPathQueryParameters3D.PathMetadataFlags
Additional information to return with the navigation path.
var pathPostprocessing: NavigationPathQueryParameters3D.PathPostProcessing
The path postprocessing applied to the raw path corridor found by the
pathfindingAlgorithm
.var pathfindingAlgorithm: NavigationPathQueryParameters3D.PathfindingAlgorithm
The pathfinding algorithm used in the path query.
var radius: Double
The radius of the avoidance agent. This is the “body” of the avoidance agent and not the avoidance maneuver starting radius (which is controlled by
neighborDistance
).var simplifyEpsilon: Double
The path simplification amount in worlds units.
var simplifyPath: Bool
If
true
a simplified version of the path will be returned with less critical path points removed. The simplification amount is controlled bysimplifyEpsilon
. The simplification uses a variant of Ramer-Douglas-Peucker algorithm for curve point decimation.var targetDesiredDistance: Double
The distance threshold before the target is considered to be reached. On reaching the target, [signal target_reached] is emitted and navigation ends (see
isNavigationFinished
and [signal navigation_finished]).var targetPosition: Vector3
If set, a new navigation path from the current agent position to the
targetPosition
is requested from the NavigationServer.var targetReached: SimpleSignal
Signals that the agent reached the target, i.e. the agent moved within
targetDesiredDistance
of thetargetPosition
. This signal is emitted only once per loaded path.var timeHorizonAgents: Double
The minimal amount of time for which this agent’s velocities, that are computed with the collision avoidance algorithm, are safe with respect to other agents. The larger the number, the sooner the agent will respond to other agents, but less freedom in choosing its velocities. A too high value will slow down agents movement considerably. Must be positive.
var timeHorizonObstacles: Double
The minimal amount of time for which this agent’s velocities, that are computed with the collision avoidance algorithm, are safe with respect to static avoidance obstacles. The larger the number, the sooner the agent will respond to static avoidance obstacles, but less freedom in choosing its velocities. A too high value will slow down agents movement considerably. Must be positive.
var use3dAvoidance: Bool
If
true
, the agent calculates avoidance velocities in 3D omnidirectionally, e.g. for games that take place in air, underwater or space. Agents using 3D avoidance only avoid other agents using 3D avoidance, and react to radius-based avoidance obstacles. They ignore any vertex-based obstacles.var velocity: Vector3
Sets the new wanted velocity for the agent. The avoidance simulation will try to fulfill this velocity if possible but will modify it to avoid collision with other agents and obstacles. When an agent is teleported to a new position, use
setVelocityForced(velocity:)
as well to reset the internal simulation velocity.var velocityComputed: Signal3
Notifies when the collision avoidance velocity is calculated. Emitted every update as long as
avoidanceEnabled
istrue
and the agent has a navigation map.var waypointReached: Signal1
Signals that the agent reached a waypoint. Emitted when the agent moves within
pathDesiredDistance
of the next position of the path.func distanceToTarget(
) -> Double Returns the distance to the target position, using the agent’s global position. The user must set
targetPosition
in order for this to be accurate.func getAvoidanceLayerValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
avoidanceLayers
bitmask is enabled, given alayerNumber
between 1 and 32.func getAvoidanceMaskValue(maskNumber: Int32
) -> Bool Returns whether or not the specified mask of the
avoidanceMask
bitmask is enabled, given amaskNumber
between 1 and 32.func getCurrentNavigationPath(
) -> PackedVector3Array Returns this agent’s current path from start to finish in global coordinates. The path only updates when the target position is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended
getNextPathPosition
once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.func getCurrentNavigationPathIndex(
) -> Int32 Returns which index the agent is currently on in the navigation path’s
PackedVector3Array
.func getCurrentNavigationResult(
) -> NavigationPathQueryResult3D? Returns the path query result for the path the agent is currently following.
func getFinalPosition(
) -> Vector3 Returns the reachable final position of the current navigation path in global coordinates. This position can change if the agent needs to update the navigation path which makes the agent emit the [signal path_changed] signal.
func getNavigationLayerValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
navigationLayers
bitmask is enabled, given alayerNumber
between 1 and 32.func getNavigationMap(
) -> RID Returns the
RID
of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. UsesetNavigationMap(_:)
to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.func getNextPathPosition(
) -> Vector3 Returns the next position in global coordinates that can be moved to, making sure that there are no static objects in the way. If the agent does not have a navigation path, it will return the position of the agent’s parent. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
func getRid(
) -> RID Returns the
RID
of this agent on theNavigationServer3D
.func isNavigationFinished(
) -> Bool Returns
true
if the agent’s navigation has finished. If the target is reachable, navigation ends when the target is reached. If the target is unreachable, navigation ends when the last waypoint of the path is reached.func isTargetReachable(
) -> Bool Returns
true
ifgetFinalPosition
is withintargetDesiredDistance
of thetargetPosition
.func isTargetReached(
) -> Bool Returns
true
if the agent reached the target, i.e. the agent moved withintargetDesiredDistance
of thetargetPosition
. It may not always be possible to reach the target but it should always be possible to reach the final position. SeegetFinalPosition
.func setAvoidanceLayerValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in theavoidanceLayers
bitmask, given alayerNumber
between 1 and 32.func setAvoidanceMaskValue(maskNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified mask in theavoidanceMask
bitmask, given amaskNumber
between 1 and 32.func setNavigationLayerValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thenavigationLayers
bitmask, given alayerNumber
between 1 and 32.func setNavigationMap(RID
) Sets the
RID
of the navigation map this NavigationAgent node should use and also updates theagent
on the NavigationServer.func setVelocityForced(velocity: Vector3
) Replaces the internal velocity in the collision avoidance simulation with
velocity
. When an agent is teleported to a new position this function should be used in the same frame. If called frequently this function can get agents stuck.
Citizens in SwiftGodot
Instance members
var emitted: Void
You can await this property to wait for the signal to be emitted once
func connect(flags: Object.ConnectFlags, @escaping (_ safeVelocity: Vector3) -> ()
) -> Object Connects the signal to the specified callback
func disconnect(Object
) Disconnects a signal that was previously connected, the return value from calling
connect(flags:_:)