SNavMeshAgent
Index
Functions Index
| Function Name |
|---|
| float GetAreaCost (int areaIndex) |
| void Move (SVector movement) |
| void Resume () |
| void SetAreaCost (int areaIndex, float cost) |
| void Stop () |
| void SetDestination (SVector position) |
| void Warp (SVector position) |
Properties Index
| Property Name |
|---|
bool Enabled get set |
float Accelleration get set |
float AngularSpeed get set |
int AreaMask get set |
bool AutoRepath get set |
bool AutoBraking get set |
bool AutoTraverseOffMeshLink get set |
int AvoidancePriority get set |
float BaseOffset get set |
SVector DesiredVelocity get |
SVector Destination get set |
bool HasPath get |
float Height get set |
bool IsOnNavMesh get |
bool IsOnOffMeshLink get |
bool IsPathStale get |
SVector NextPosition get set |
SVector PathEndPosition get |
bool PathPending get |
float Radius get set |
float RemainingDistance get |
float Speed get set |
SVector SteeringTarget get |
float StoppingDistance get set |
bool UpdatePosition get set |
bool UpdateRotation get set |
SVector Velocity get |
SGameObject GameObject get |
Functions
GetAreaCost
float GetAreaCost (int areaIndex)
Function Description
| Parameter | Type | Description |
|---|---|---|
- Lua
floatCost = Space.Host.ExecutingObject.NavMeshAgent.GetAreaCost(1)
Move
void Move (SVector movement)
Apply relative movement to current position.
| Parameter | Type | Description |
|---|---|---|
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Move(Vector.New(2,0,0))
Resume
void Resume ()
Resume the NavMesh agent.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Resume()
- Lua
agentobject = Space.Scene.Find("Cube")
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
counts = 0
--stop first, then resume.
function StopAndResume()
counts = counts +1
if counts > 10 then
agent.Stop()
end
if counts > 50 then
agent.Resume()
end
end
agentobject.SubscribeToEvents()
agentobject.OnUpdate(StopAndResume)
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
--set destination.
SetAreaCost
void SetAreaCost (int areaIndex, float cost)
Sets the cost for traversing over areas of the area type.
| Parameter | Type | Description |
|---|---|---|
- Lua
Space.Host.ExecutingObject.NavMeshAgent.SetAreaCost(1, 10.0)
Stop
void Stop ()
To stop the NavMesh agent.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Stop()
SetDestination
void SetDestination (SVector position)
Set or update the destination.
| Parameter | Type | Description |
|---|---|---|
- Lua
Space.Host.ExecutingObject.NavMeshAgent.SetDestination(Vector.New(10,0,0))
Warp
void Warp (SVector position)
Warp to the position you want, also you can set agent's world position and vector to make this act as Move(SVector position).
| Parameter | Type | Description |
|---|---|---|
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Warp(Vector.New(10,0,0))
Properties
Enabled
bool Enabled get set
Enable or disable this component.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Enabled = false
- Lua
--clicking this object will Enable/Disable it's Nav Mesh Agent component
thisGameObject = Space.Host.ExecutingObject
component = thisGameObject.NavMeshAgent
OnClick = function()
component.Enabled = not component.Enabled
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
Accelleration
float Accelleration get set
The maximum acceleration of an agent as it follows a path.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Accelleration = 60
AngularSpeed
float AngularSpeed get set
Maximum turning speed in while following a path.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.AngularSpeed = 60
AreaMask
int AreaMask get set
Specifies which NavMesh area is passable.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.AreaMask = 3
AutoRepath
bool AutoRepath get set
Set the agent attempt to acquire a new path if the existing path becomes invalid.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.AutoRepath = false
AutoBraking
bool AutoBraking get set
Set the agent brake automatically to avoid overshooting the destination point.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.AutoBraking = false
AutoTraverseOffMeshLink
bool AutoTraverseOffMeshLink get set
Set the agent move across OffMeshLinks automatically.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.AutoTraverseOffMeshLink = false
AvoidancePriority
int AvoidancePriority get set
The avoidance priority level.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.AvoidancePriority = 10
BaseOffset
float BaseOffset get set
The relative vertical displacement of the GameObject.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.BaseOffset = 3
DesiredVelocity
SVector DesiredVelocity get
The desired velocity of the agent including any potential contribution from avoidance.
- Lua
vectorVelocity = Space.Host.ExecutingObject.NavMeshAgent.DesiredVelocity
Destination
SVector Destination get set
The desired velocity of the agent including any potential contribution from avoidance.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Destination = Vector.New(10,0,0)
HasPath
bool HasPath get
Does the agent currently have a path?
- Lua
hasPath = Space.Host.ExecutingObject.NavMeshAgent.HasPath
Height
float Height get set
The height of the agent for purposes of passing under obstacles, etc.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Height = 5
IsOnNavMesh
bool IsOnNavMesh get
Is the agent currently bound to the navmesh?
- Lua
isOn = Space.Host.ExecutingObject.NavMeshAgent.IsOnNavMesh
IsOnOffMeshLink
bool IsOnOffMeshLink get
Is the agent currently positioned on an OffMeshLink?
- Lua
isOnOff = Space.Host.ExecutingObject.NavMeshAgent.IsOnOffMeshLink
IsPathStale
bool IsPathStale get
Is the current path stale?
- Lua
isStale = Space.Host.ExecutingObject.NavMeshAgent.IsPathStale
NextPosition
SVector NextPosition get set
Get or set the simulation position of the navmesh agent.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.NextPosition = Vector.New(10, 0, 0)
PathEndPosition
SVector PathEndPosition get
End positon of navigation.
- Lua
vectorPathEndPos = Space.Host.ExecutingObject.NavMeshAgent.PathEndPosition
PathPending
bool PathPending get
Is a path in the process of being computed but not yet ready?
- Lua
isPending = Space.Host.ExecutingObject.NavMeshAgent.PathPending
Radius
float Radius get set
The avoidance radius for the agent.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Radius = 5
RemainingDistance
float RemainingDistance get
The distance between the agent's position and the destination on the current path.
- Lua
vectorDist = Space.Host.ExecutingObject.NavMeshAgent.RemainingDistance
Speed
float Speed get set
Maximum movement speed when following a path.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.Speed = 20
SteeringTarget
SVector SteeringTarget get
Get the current steering target along the path.
- Lua
vectorSteeringTarget = Space.Host.ExecutingObject.NavMeshAgent.SteeringTarget
StoppingDistance
float StoppingDistance get set
Stop within this distance from the target position.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.StoppingDistance = 2
UpdatePosition
bool UpdatePosition get set
Get or set whether the transform position is synchronized with the simulated agent position.
- Lua
Space.Host.ExecutingObject.NavMeshAgent.UpdatePosition = true
UpdateRotation
bool UpdateRotation get set
Should the agent update the transform orientation?
- Lua
Space.Host.ExecutingObject.NavMeshAgent.UpdateRotation = true
Velocity
SVector Velocity get
access the current velocity of the NavMeshAgent component, or set a velocity to control the agent manually.
- Lua
vectorVelocity = Space.Host.ExecutingObject.NavMeshAgent.Velocity
GameObject
SGameObject GameObject get
Property Description
- Lua
theGameObject = Space.Host.ExecutingObject.NavMeshAgent.GameObject