Documentation
¶
Overview ¶
A 3D agent used to pathfind to a position while avoiding static and dynamic obstacles. The calculation can be used by the parent node to dynamically move it along the path. Requires navigation data to work correctly.
Dynamic obstacles are avoided using RVO collision avoidance. Avoidance is computed before physics, so the pathfinding information can be used safely in the physics step.
Note: After setting the Instance.TargetPosition property, the Instance.GetNextPathPosition method must be used once every physics frame to update the internal path logic of the navigation agent. The vector position it returns should be used as the next movement position for the agent's parent node.
Note: Several methods of this class, such as Instance.GetNextPathPosition, can trigger a new path calculation. Calling these in your callback to an agent's signal, such as Instance.OnWaypointReached, can cause infinite recursion. It is recommended to call these methods in the physics step or, alternatively, delay their call until the end of the frame (see graphics.gd/classdb/Object.Instance.CallDeferred or [Object.ConnectDeferred]).
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsNavigationAgent3D() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AvoidanceEnabled() bool
- func (self Instance) AvoidanceLayers() int
- func (self Instance) AvoidanceMask() int
- func (self Instance) AvoidancePriority() Float.X
- func (self Instance) DebugEnabled() bool
- func (self Instance) DebugPathCustomColor() Color.RGBA
- func (self Instance) DebugPathCustomPointSize() Float.X
- func (self Instance) DebugUseCustom() bool
- func (self Instance) DistanceToTarget() Float.X
- func (self Instance) GetAvoidanceLayerValue(layer_number int) bool
- func (self Instance) GetAvoidanceMaskValue(mask_number int) bool
- func (self Instance) GetCurrentNavigationPath() []Vector3.XYZ
- func (self Instance) GetCurrentNavigationPathIndex() int
- func (self Instance) GetCurrentNavigationResult() NavigationPathQueryResult3D.Instance
- func (self Instance) GetFinalPosition() Vector3.XYZ
- func (self Instance) GetNavigationLayerValue(layer_number int) bool
- func (self Instance) GetNavigationMap() RID.NavigationMap3D
- func (self Instance) GetNextPathPosition() Vector3.XYZ
- func (self Instance) GetPathLength() Float.X
- func (self Instance) GetRid() RID.NavigationAgent3D
- func (self Instance) Height() Float.X
- func (self Instance) ID() ID
- func (self Instance) IsNavigationFinished() bool
- func (self Instance) IsTargetReachable() bool
- func (self Instance) IsTargetReached() bool
- func (self Instance) KeepYVelocity() bool
- func (self Instance) MaxNeighbors() int
- func (self Instance) MaxSpeed() Float.X
- func (self Instance) NavigationLayers() int
- func (self Instance) NeighborDistance() Float.X
- func (self Instance) OnLinkReached(cb func(details map[any]any), flags ...Signal.Flags)
- func (self Instance) OnNavigationFinished(cb func(), flags ...Signal.Flags)
- func (self Instance) OnPathChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnTargetReached(cb func(), flags ...Signal.Flags)
- func (self Instance) OnVelocityComputed(cb func(safe_velocity Vector3.XYZ), flags ...Signal.Flags)
- func (self Instance) OnWaypointReached(cb func(details map[any]any), flags ...Signal.Flags)
- func (self Instance) PathDesiredDistance() Float.X
- func (self Instance) PathHeightOffset() Float.X
- func (self Instance) PathMaxDistance() Float.X
- func (self Instance) PathMetadataFlags() NavigationPathQueryParameters3D.PathMetadataFlags
- func (self Instance) PathPostprocessing() NavigationPathQueryParameters3D.PathPostProcessing
- func (self Instance) PathReturnMaxLength() Float.X
- func (self Instance) PathReturnMaxRadius() Float.X
- func (self Instance) PathSearchMaxDistance() Float.X
- func (self Instance) PathSearchMaxPolygons() int
- func (self Instance) PathfindingAlgorithm() NavigationPathQueryParameters3D.PathfindingAlgorithm
- func (self Instance) Radius() Float.X
- func (self Instance) SetAvoidanceEnabled(value bool)
- func (self Instance) SetAvoidanceLayerValue(layer_number int, value bool)
- func (self Instance) SetAvoidanceLayers(value int)
- func (self Instance) SetAvoidanceMask(value int)
- func (self Instance) SetAvoidanceMaskValue(mask_number int, value bool)
- func (self Instance) SetAvoidancePriority(value Float.X)
- func (self Instance) SetDebugEnabled(value bool)
- func (self Instance) SetDebugPathCustomColor(value Color.RGBA)
- func (self Instance) SetDebugPathCustomPointSize(value Float.X)
- func (self Instance) SetDebugUseCustom(value bool)
- func (self Instance) SetHeight(value Float.X)
- func (self Instance) SetKeepYVelocity(value bool)
- func (self Instance) SetMaxNeighbors(value int)
- func (self Instance) SetMaxSpeed(value Float.X)
- func (self Instance) SetNavigationLayerValue(layer_number int, value bool)
- func (self Instance) SetNavigationLayers(value int)
- func (self Instance) SetNavigationMap(navigation_map RID.NavigationMap3D)
- func (self Instance) SetNeighborDistance(value Float.X)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPathDesiredDistance(value Float.X)
- func (self Instance) SetPathHeightOffset(value Float.X)
- func (self Instance) SetPathMaxDistance(value Float.X)
- func (self Instance) SetPathMetadataFlags(value NavigationPathQueryParameters3D.PathMetadataFlags)
- func (self Instance) SetPathPostprocessing(value NavigationPathQueryParameters3D.PathPostProcessing)
- func (self Instance) SetPathReturnMaxLength(value Float.X)
- func (self Instance) SetPathReturnMaxRadius(value Float.X)
- func (self Instance) SetPathSearchMaxDistance(value Float.X)
- func (self Instance) SetPathSearchMaxPolygons(value int)
- func (self Instance) SetPathfindingAlgorithm(value NavigationPathQueryParameters3D.PathfindingAlgorithm)
- func (self Instance) SetRadius(value Float.X)
- func (self Instance) SetSimplifyEpsilon(value Float.X)
- func (self Instance) SetSimplifyPath(value bool)
- func (self Instance) SetTargetDesiredDistance(value Float.X)
- func (self Instance) SetTargetPosition(value Vector3.XYZ)
- func (self Instance) SetTimeHorizonAgents(value Float.X)
- func (self Instance) SetTimeHorizonObstacles(value Float.X)
- func (self Instance) SetUse3dAvoidance(value bool)
- func (self Instance) SetVelocity(value Vector3.XYZ)
- func (self Instance) SetVelocityForced(velocity Vector3.XYZ)
- func (self Instance) SimplifyEpsilon() Float.X
- func (self Instance) SimplifyPath() bool
- func (self Instance) TargetDesiredDistance() Float.X
- func (self Instance) TargetPosition() Vector3.XYZ
- func (self Instance) TimeHorizonAgents() Float.X
- func (self Instance) TimeHorizonObstacles() Float.X
- func (self Instance) Use3dAvoidance() bool
- func (self Instance) Velocity() Vector3.XYZ
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsNavigationAgent3D ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.NavigationAgent3D
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsNavigationAgent3D ¶
func (Instance) AvoidanceEnabled ¶
func (Instance) AvoidanceLayers ¶
func (Instance) AvoidanceMask ¶
func (Instance) AvoidancePriority ¶
func (Instance) DebugEnabled ¶
func (Instance) DebugPathCustomColor ¶
func (Instance) DebugPathCustomPointSize ¶
func (Instance) DebugUseCustom ¶
func (Instance) DistanceToTarget ¶
Returns the distance to the target position, using the agent's global position. The user must set Instance.TargetPosition in order for this to be accurate.
func (Instance) GetAvoidanceLayerValue ¶
Returns whether or not the specified layer of the Instance.AvoidanceLayers bitmask is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetAvoidanceMaskValue ¶
Returns whether or not the specified mask of the Instance.AvoidanceMask bitmask is enabled, given a 'mask_number' between 1 and 32.
func (Instance) GetCurrentNavigationPath ¶
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 Instance.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 (Instance) GetCurrentNavigationPathIndex ¶
Returns which index the agent is currently on in the navigation path's [][Vector3.XYZ].
func (Instance) GetCurrentNavigationResult ¶
func (self Instance) GetCurrentNavigationResult() NavigationPathQueryResult3D.Instance
Returns the path query result for the path the agent is currently following.
func (Instance) GetFinalPosition ¶
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 Instance.OnPathChanged signal.
func (Instance) GetNavigationLayerValue ¶
Returns whether or not the specified layer of the Instance.NavigationLayers bitmask is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetNavigationMap ¶
func (self Instance) GetNavigationMap() RID.NavigationMap3D
Returns the [Resource.ID] 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. Use Instance.SetNavigationMap to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
func (Instance) GetNextPathPosition ¶
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 (Instance) GetPathLength ¶
Returns the length of the currently calculated path. The returned value is 0.0, if the path is still calculating or no calculation has been requested yet.
func (Instance) GetRid ¶
func (self Instance) GetRid() RID.NavigationAgent3D
Returns the [Resource.ID] of this agent on the graphics.gd/classdb/NavigationServer3D.
func (Instance) IsNavigationFinished ¶
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.
Note: While true prefer to stop calling update functions like Instance.GetNextPathPosition. This avoids jittering the standing agent due to calling repeated path updates.
func (Instance) IsTargetReachable ¶
Returns true if Instance.GetFinalPosition is within Instance.TargetDesiredDistance of the Instance.TargetPosition.
func (Instance) IsTargetReached ¶
Returns true if the agent reached the target, i.e. the agent moved within Instance.TargetDesiredDistance of the Instance.TargetPosition. It may not always be possible to reach the target but it should always be possible to reach the final position. See Instance.GetFinalPosition.
func (Instance) KeepYVelocity ¶
func (Instance) MaxNeighbors ¶
func (Instance) NavigationLayers ¶
func (Instance) NeighborDistance ¶
func (Instance) OnLinkReached ¶
func (Instance) OnNavigationFinished ¶
func (Instance) OnPathChanged ¶
func (Instance) OnTargetReached ¶
func (Instance) OnVelocityComputed ¶
func (Instance) OnWaypointReached ¶
func (Instance) PathDesiredDistance ¶
func (Instance) PathHeightOffset ¶
func (Instance) PathMaxDistance ¶
func (Instance) PathMetadataFlags ¶
func (self Instance) PathMetadataFlags() NavigationPathQueryParameters3D.PathMetadataFlags
func (Instance) PathPostprocessing ¶
func (self Instance) PathPostprocessing() NavigationPathQueryParameters3D.PathPostProcessing
func (Instance) PathReturnMaxLength ¶
func (Instance) PathReturnMaxRadius ¶
func (Instance) PathSearchMaxDistance ¶
func (Instance) PathSearchMaxPolygons ¶
func (Instance) PathfindingAlgorithm ¶
func (self Instance) PathfindingAlgorithm() NavigationPathQueryParameters3D.PathfindingAlgorithm
func (Instance) SetAvoidanceEnabled ¶
func (Instance) SetAvoidanceLayerValue ¶
Based on 'value', enables or disables the specified layer in the Instance.AvoidanceLayers bitmask, given a 'layer_number' between 1 and 32.
func (Instance) SetAvoidanceLayers ¶
func (Instance) SetAvoidanceMask ¶
func (Instance) SetAvoidanceMaskValue ¶
Based on 'value', enables or disables the specified mask in the Instance.AvoidanceMask bitmask, given a 'mask_number' between 1 and 32.
func (Instance) SetAvoidancePriority ¶
func (Instance) SetDebugEnabled ¶
func (Instance) SetDebugPathCustomColor ¶
func (Instance) SetDebugPathCustomPointSize ¶
func (Instance) SetDebugUseCustom ¶
func (Instance) SetKeepYVelocity ¶
func (Instance) SetMaxNeighbors ¶
func (Instance) SetMaxSpeed ¶
func (Instance) SetNavigationLayerValue ¶
Based on 'value', enables or disables the specified layer in the Instance.NavigationLayers bitmask, given a 'layer_number' between 1 and 32.
func (Instance) SetNavigationLayers ¶
func (Instance) SetNavigationMap ¶
func (self Instance) SetNavigationMap(navigation_map RID.NavigationMap3D)
Sets the [Resource.ID] of the navigation map this NavigationAgent node should use and also updates the agent on the NavigationServer.
func (Instance) SetNeighborDistance ¶
func (Instance) SetPathDesiredDistance ¶
func (Instance) SetPathHeightOffset ¶
func (Instance) SetPathMaxDistance ¶
func (Instance) SetPathMetadataFlags ¶
func (self Instance) SetPathMetadataFlags(value NavigationPathQueryParameters3D.PathMetadataFlags)
func (Instance) SetPathPostprocessing ¶
func (self Instance) SetPathPostprocessing(value NavigationPathQueryParameters3D.PathPostProcessing)
func (Instance) SetPathReturnMaxLength ¶
func (Instance) SetPathReturnMaxRadius ¶
func (Instance) SetPathSearchMaxDistance ¶
func (Instance) SetPathSearchMaxPolygons ¶
func (Instance) SetPathfindingAlgorithm ¶
func (self Instance) SetPathfindingAlgorithm(value NavigationPathQueryParameters3D.PathfindingAlgorithm)
func (Instance) SetSimplifyEpsilon ¶
func (Instance) SetSimplifyPath ¶
func (Instance) SetTargetDesiredDistance ¶
func (Instance) SetTargetPosition ¶
func (Instance) SetTimeHorizonAgents ¶
func (Instance) SetTimeHorizonObstacles ¶
func (Instance) SetUse3dAvoidance ¶
func (Instance) SetVelocity ¶
func (Instance) SetVelocityForced ¶
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.