Documentation
¶
Overview ¶
A 2D 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 TargetPosition property, the 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 GetNextPathPosition, can trigger a new path calculation. Calling these in your callback to an agent's signal, such as 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 Object.CallDeferred or [Object.ConnectDeferred]).
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsNavigationAgent2D() 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) DebugPathCustomLineWidth() Float.X
- 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() []Vector2.XY
- func (self Instance) GetCurrentNavigationPathIndex() int
- func (self Instance) GetCurrentNavigationResult() NavigationPathQueryResult2D.Instance
- func (self Instance) GetFinalPosition() Vector2.XY
- func (self Instance) GetNavigationLayerValue(layer_number int) bool
- func (self Instance) GetNavigationMap() RID.NavigationMap2D
- func (self Instance) GetNextPathPosition() Vector2.XY
- func (self Instance) GetPathLength() Float.X
- func (self Instance) GetRid() RID.NavigationAgent2D
- func (self Instance) ID() ID
- func (self Instance) IsNavigationFinished() bool
- func (self Instance) IsTargetReachable() bool
- func (self Instance) IsTargetReached() 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 Vector2.XY), 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) PathMaxDistance() Float.X
- func (self Instance) PathMetadataFlags() NavigationPathQueryParameters2D.PathMetadataFlags
- func (self Instance) PathPostprocessing() NavigationPathQueryParameters2D.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() NavigationPathQueryParameters2D.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) SetDebugPathCustomLineWidth(value Float.X)
- func (self Instance) SetDebugPathCustomPointSize(value Float.X)
- func (self Instance) SetDebugUseCustom(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.NavigationMap2D)
- 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) SetPathMaxDistance(value Float.X)
- func (self Instance) SetPathMetadataFlags(value NavigationPathQueryParameters2D.PathMetadataFlags)
- func (self Instance) SetPathPostprocessing(value NavigationPathQueryParameters2D.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 NavigationPathQueryParameters2D.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 Vector2.XY)
- func (self Instance) SetTimeHorizonAgents(value Float.X)
- func (self Instance) SetTimeHorizonObstacles(value Float.X)
- func (self Instance) SetVelocity(value Vector2.XY)
- func (self Instance) SetVelocityForced(velocity Vector2.XY)
- func (self Instance) SimplifyEpsilon() Float.X
- func (self Instance) SimplifyPath() bool
- func (self Instance) TargetDesiredDistance() Float.X
- func (self Instance) TargetPosition() Vector2.XY
- func (self Instance) TimeHorizonAgents() Float.X
- func (self Instance) TimeHorizonObstacles() Float.X
- func (self Instance) Velocity() Vector2.XY
- 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]) AsNavigationAgent2D ¶
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.NavigationAgent2D
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) AsNavigationAgent2D ¶
func (Instance) AvoidanceEnabled ¶
If true the agent is registered for an RVO avoidance callback on the NavigationServer2D. When Velocity is used and the processing is completed a safe_velocity Vector2 is received with a signal connection to OnVelocityComputed. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.
func (Instance) AvoidanceLayers ¶
A bitfield determining the avoidance layers for this NavigationAgent. Other agents with a matching bit on the AvoidanceMask will avoid this agent.
func (Instance) AvoidanceMask ¶
A bitfield determining what other avoidance agents and obstacles this NavigationAgent will avoid when a bit matches at least one of their AvoidanceLayers.
func (Instance) AvoidancePriority ¶
The agent does not adjust the velocity for other agents that would match the AvoidanceMask but have a lower AvoidancePriority. This in turn makes the other agents with lower priority adjust their velocities even more to avoid collision with this agent.
func (Instance) DebugEnabled ¶
If true shows debug visuals for this agent.
func (Instance) DebugPathCustomColor ¶
If DebugUseCustom is true uses this color for this agent instead of global color.
func (Instance) DebugPathCustomLineWidth ¶
If DebugUseCustom is true uses this line width for rendering paths for this agent instead of global line width.
func (Instance) DebugPathCustomPointSize ¶
If DebugUseCustom is true uses this rasterized point size for rendering path points for this agent instead of global point size.
func (Instance) DebugUseCustom ¶
If true uses the defined DebugPathCustomColor for this agent instead of global color.
func (Instance) DistanceToTarget ¶
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 (Instance) GetAvoidanceLayerValue ¶
Returns whether or not the specified layer of the AvoidanceLayers bitmask is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetAvoidanceMaskValue ¶
Returns whether or not the specified mask of the 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 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 []Vector2.XY.
func (Instance) GetCurrentNavigationResult ¶
func (self Instance) GetCurrentNavigationResult() NavigationPathQueryResult2D.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 OnPathChanged signal.
func (Instance) GetNavigationLayerValue ¶
Returns whether or not the specified layer of the NavigationLayers bitmask is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetNavigationMap ¶
func (self Instance) GetNavigationMap() RID.NavigationMap2D
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 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.NavigationAgent2D
Returns the Resource.ID of this agent on the NavigationServer2D.
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 GetNextPathPosition. This avoids jittering the standing agent due to calling repeated path updates.
func (Instance) IsTargetReachable ¶
Returns true if GetFinalPosition is within TargetDesiredDistance of the TargetPosition.
func (Instance) IsTargetReached ¶
Returns true if the agent reached the target, i.e. the agent moved within TargetDesiredDistance of the TargetPosition. It may not always be possible to reach the target but it should always be possible to reach the final position. See GetFinalPosition.
func (Instance) MaxNeighbors ¶
The maximum number of neighbors for the agent to consider.
func (Instance) NavigationLayers ¶
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.
func (Instance) NeighborDistance ¶
The distance to search for other agents.
func (Instance) OnLinkReached ¶
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.
The details dictionary may contain the following keys depending on the value of PathMetadataFlags:
- position: The start position of the link that was reached.
- type: Always [Navigationpathqueryresult2d.PathSegmentTypeLink].
- rid: The Resource.ID of the link.
- owner: The object which manages the link (usually NavigationLink2D).
- link_entry_position: If owner is available and the owner is a NavigationLink2D, it will contain the global position of the link's point the agent is entering.
- link_exit_position: If owner is available and the owner is a NavigationLink2D, it will contain the global position of the link's point which the agent is exiting.
func (Instance) OnNavigationFinished ¶
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.
This signal will be emitted just after OnTargetReached when the target is reachable.
func (Instance) OnPathChanged ¶
Emitted when the agent had to update the loaded path:
- because path was previously empty.
- because navigation map has changed.
- because agent pushed further away from the current path segment than the PathMaxDistance.
func (Instance) OnTargetReached ¶
Signals that the agent reached the target, i.e. the agent moved within TargetDesiredDistance of the TargetPosition. This signal is emitted only once per loaded path.
This signal will be emitted just before OnNavigationFinished when the target is reachable.
It may not always be possible to reach the target but it should always be possible to reach the final position. See GetFinalPosition.
func (Instance) OnVelocityComputed ¶
Notifies when the collision avoidance velocity is calculated. Emitted every update as long as AvoidanceEnabled is true and the agent has a navigation map.
func (Instance) OnWaypointReached ¶
Signals that the agent reached a waypoint. Emitted when the agent moves within PathDesiredDistance of the next position of the path.
The details dictionary may contain the following keys depending on the value of PathMetadataFlags:
- position: The position of the waypoint that was reached.
- type: The type of navigation primitive (region or link) that contains this waypoint.
- rid: The Resource.ID of the containing navigation primitive (region or link).
- owner: The object which manages the containing navigation primitive (region or link).
func (Instance) PathDesiredDistance ¶
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.
func (Instance) PathMaxDistance ¶
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.
func (Instance) PathMetadataFlags ¶
func (self Instance) PathMetadataFlags() NavigationPathQueryParameters2D.PathMetadataFlags
Additional information to return with the navigation path.
func (Instance) PathPostprocessing ¶
func (self Instance) PathPostprocessing() NavigationPathQueryParameters2D.PathPostProcessing
The path postprocessing applied to the raw path corridor found by the PathfindingAlgorithm.
func (Instance) PathReturnMaxLength ¶
The maximum allowed length of the returned path in world units. A path will be clipped when going over this length.
func (Instance) PathReturnMaxRadius ¶
The maximum allowed radius in world units that the returned path can be from the path start. The path will be clipped when going over this radius. Compared to PathReturnMaxLength, this allows the agent to go that much further, if they need to walk around a corner.
Note: This will perform a sphere clip considering only the actual navigation mesh path points with the first path position being the sphere's center.
func (Instance) PathSearchMaxDistance ¶
The maximum distance a searched polygon can be away from the start polygon before the pathfinding cancels the search for a path to the (possibly unreachable or very far away) target position polygon. In this case the pathfinding resets and builds a path from the start polygon to the polygon that was found closest to the target position so far. A value of 0 or below counts as unlimited. In case of unlimited the pathfinding will search all polygons connected with the start polygon until either the target position polygon is found or all available polygon search options are exhausted.
func (Instance) PathSearchMaxPolygons ¶
The maximum number of polygons that are searched before the pathfinding cancels the search for a path to the (possibly unreachable or very far away) target position polygon. In this case the pathfinding resets and builds a path from the start polygon to the polygon that was found closest to the target position so far. A value of 0 or below counts as unlimited. In case of unlimited the pathfinding will search all polygons connected with the start polygon until either the target position polygon is found or all available polygon search options are exhausted.
func (Instance) PathfindingAlgorithm ¶
func (self Instance) PathfindingAlgorithm() NavigationPathQueryParameters2D.PathfindingAlgorithm
The pathfinding algorithm used in the path query.
func (Instance) Radius ¶
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).
Does not affect normal pathfinding. To change an actor's pathfinding radius bake NavigationPolygon resources with a different NavigationPolygon.AgentRadius property and use different navigation maps for each actor size.
func (Instance) SetAvoidanceEnabled ¶
SetAvoidanceEnabled sets the property returned by [GetAvoidanceEnabled].
func (Instance) SetAvoidanceLayerValue ¶
Based on 'value', enables or disables the specified layer in the AvoidanceLayers bitmask, given a 'layer_number' between 1 and 32.
func (Instance) SetAvoidanceLayers ¶
SetAvoidanceLayers sets the property returned by [GetAvoidanceLayers].
func (Instance) SetAvoidanceMask ¶
SetAvoidanceMask sets the property returned by [GetAvoidanceMask].
func (Instance) SetAvoidanceMaskValue ¶
Based on 'value', enables or disables the specified mask in the AvoidanceMask bitmask, given a 'mask_number' between 1 and 32.
func (Instance) SetAvoidancePriority ¶
SetAvoidancePriority sets the property returned by [GetAvoidancePriority].
func (Instance) SetDebugEnabled ¶
SetDebugEnabled sets the property returned by [GetDebugEnabled].
func (Instance) SetDebugPathCustomColor ¶
SetDebugPathCustomColor sets the property returned by [GetDebugPathCustomColor].
func (Instance) SetDebugPathCustomLineWidth ¶
SetDebugPathCustomLineWidth sets the property returned by [GetDebugPathCustomLineWidth].
func (Instance) SetDebugPathCustomPointSize ¶
SetDebugPathCustomPointSize sets the property returned by [GetDebugPathCustomPointSize].
func (Instance) SetDebugUseCustom ¶
SetDebugUseCustom sets the property returned by [GetDebugUseCustom].
func (Instance) SetMaxNeighbors ¶
SetMaxNeighbors sets the property returned by [GetMaxNeighbors].
func (Instance) SetMaxSpeed ¶
SetMaxSpeed sets the property returned by [GetMaxSpeed].
func (Instance) SetNavigationLayerValue ¶
Based on 'value', enables or disables the specified layer in the NavigationLayers bitmask, given a 'layer_number' between 1 and 32.
func (Instance) SetNavigationLayers ¶
SetNavigationLayers sets the property returned by [GetNavigationLayers].
func (Instance) SetNavigationMap ¶
func (self Instance) SetNavigationMap(navigation_map RID.NavigationMap2D)
Sets the Resource.ID of the navigation map this NavigationAgent node should use and also updates the agent on the NavigationServer.
func (Instance) SetNeighborDistance ¶
SetNeighborDistance sets the property returned by [GetNeighborDistance].
func (Instance) SetPathDesiredDistance ¶
SetPathDesiredDistance sets the property returned by [GetPathDesiredDistance].
func (Instance) SetPathMaxDistance ¶
SetPathMaxDistance sets the property returned by [GetPathMaxDistance].
func (Instance) SetPathMetadataFlags ¶
func (self Instance) SetPathMetadataFlags(value NavigationPathQueryParameters2D.PathMetadataFlags)
SetPathMetadataFlags sets the property returned by [GetPathMetadataFlags].
func (Instance) SetPathPostprocessing ¶
func (self Instance) SetPathPostprocessing(value NavigationPathQueryParameters2D.PathPostProcessing)
SetPathPostprocessing sets the property returned by [GetPathPostprocessing].
func (Instance) SetPathReturnMaxLength ¶
SetPathReturnMaxLength sets the property returned by [GetPathReturnMaxLength].
func (Instance) SetPathReturnMaxRadius ¶
SetPathReturnMaxRadius sets the property returned by [GetPathReturnMaxRadius].
func (Instance) SetPathSearchMaxDistance ¶
SetPathSearchMaxDistance sets the property returned by [GetPathSearchMaxDistance].
func (Instance) SetPathSearchMaxPolygons ¶
SetPathSearchMaxPolygons sets the property returned by [GetPathSearchMaxPolygons].
func (Instance) SetPathfindingAlgorithm ¶
func (self Instance) SetPathfindingAlgorithm(value NavigationPathQueryParameters2D.PathfindingAlgorithm)
SetPathfindingAlgorithm sets the property returned by [GetPathfindingAlgorithm].
func (Instance) SetSimplifyEpsilon ¶
SetSimplifyEpsilon sets the property returned by [GetSimplifyEpsilon].
func (Instance) SetSimplifyPath ¶
SetSimplifyPath sets the property returned by [GetSimplifyPath].
func (Instance) SetTargetDesiredDistance ¶
SetTargetDesiredDistance sets the property returned by [GetTargetDesiredDistance].
func (Instance) SetTargetPosition ¶
SetTargetPosition sets the property returned by [GetTargetPosition].
func (Instance) SetTimeHorizonAgents ¶
SetTimeHorizonAgents sets the property returned by [GetTimeHorizonAgents].
func (Instance) SetTimeHorizonObstacles ¶
SetTimeHorizonObstacles sets the property returned by [GetTimeHorizonObstacles].
func (Instance) SetVelocity ¶
SetVelocity sets the property returned by [GetVelocity].
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.
func (Instance) SimplifyEpsilon ¶
The path simplification amount in worlds units.
func (Instance) SimplifyPath ¶
If true a simplified version of the path will be returned with less critical path points removed. The simplification amount is controlled by SimplifyEpsilon. The simplification uses a variant of Ramer-Douglas-Peucker algorithm for curve point decimation.
Path simplification can be helpful to mitigate various path following issues that can arise with certain agent types and script behaviors. E.g. "steering" agents or avoidance in "open fields".
func (Instance) TargetDesiredDistance ¶
The distance threshold before the target is considered to be reached. On reaching the target, OnTargetReached is emitted and navigation ends (see IsNavigationFinished and OnNavigationFinished).
You can make navigation end early by setting this property to a value greater than PathDesiredDistance (navigation will end before reaching the last waypoint).
You can also make navigation end closer to the target than each individual path position by setting this property to a value lower than PathDesiredDistance (navigation won't immediately end when reaching the last waypoint). However, if the value set is too low, the agent will be stuck in a repath loop because it will constantly overshoot the distance to the target on each physics frame update.
func (Instance) TargetPosition ¶
If set, a new navigation path from the current agent position to the TargetPosition is requested from the NavigationServer.
func (Instance) TimeHorizonAgents ¶
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.
func (Instance) TimeHorizonObstacles ¶
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.
func (Instance) Velocity ¶
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 as well to reset the internal simulation velocity.