Navigation mesh agent. is attached to a mobile character in the game to allow it to navigate the Scene using the NavMesh.
Apply relative movement to current position.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Move(Vector.New(2,0,0))
Resume the NavMesh agent.
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
Sets the cost for traversing over areas of the area type.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.SetAreaCost(2,20)
To stop the NavMesh agent.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
--set destination.
agent.Stop()
Set or update the destination.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.SetDestination(Space.Scene.Find("TargetTransform").WorldPosition)
Wrap to the position you want, also you can set agent's world position and vector to make this act as Move(SVector position).
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Wrap(Vector.New(2,0,0)+agent.GameObject.WorldPosition)
Enable or disable this component.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Enabled = false
--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)
The maximum acceleration of an agent as it follows a path.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Accelleration = 60
The maximum acceleration of an agent as it follows a path.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Accelleration = 60
Maximum turning speed in while following a path.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.AngularSpeed = 60
Specifies which NavMesh area is passable.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.AreaMask = 3
Set the agent attempt to acquire a new path if the existing path becomes invalid.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.AutoRepath = false
Set the agent brake automatically to avoid overshooting the destination point.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.AutoBraking = false
Set the agent move across OffMeshLinks automatically.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.AutoTraverseOffMeshLink = false
The avoidance priority level.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.AvoidancePriority = 60
The relative vertical displacement of the GameObject.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.BaseOffset = 3
The desired velocity of the agent including any potential contribution from avoidance.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
Space.Log(agent.DesiredVelocity.ToString())
The desired velocity of the agent including any potential contribution from avoidance.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition--set destination for target transforming.
Does the agent currently have a path?
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
Space.Log(agent.HasPath)
The height of the agent for purposes of passing under obstacles, etc.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Height = 60
Is the agent currently bound to the navmesh?
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
Space.Log(agent.IsOnNavMesh)
Is the agent currently positioned on an OffMeshLink?
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
Space.Log(agent.IsOnOffMeshLink)
Is the current path stale?
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
Space.Log(agent.IsPathStale)
Get or set the simulation position of the navmesh agent.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
function OutputNextPosition()
Space.Log(agent.NextPosition)
end
agentobject.SubscribeToEvents()
agentobject.OnUpdate(OutputNextPosition)
--register update events to navmesh agent's game object
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
End positon of navigation.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
Space.Log(agent.PatchEndPosition)
Is a path in the process of being computed but not yet ready?
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
function OutputPathPending()
Space.Log(agent.PathPending)
end
agentobject.SubscribeToEvents()
agentobject.OnUpdate(OutputPathPending)
--register update events to navmesh agent's game object
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
The avoidance radius for the agent.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Radius = 5
The distance between the agent's position and the destination on the current path.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
function OutputRemainingDistance()
Space.Log(agent.RemainingDistance)
end
agentobject.SubscribeToEvents()
agentobject.OnUpdate(OutputRemainingDistance)
--register update events to navmesh agent's game object
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
Maximum movement speed when following a path.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Speed = 20
--set speed to 20.
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
Get the current steering target along the path.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
--set destination.
Space.Log(agent.SteeringTarget.ToString())
Stop within this distance from the target position.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.StoppingDistance = 2
No documentation
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.UpdatePosition = false
--set update position to false.
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
No documentation
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
agent.UpdateRotation = false
--set update Rotation to false.
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
access the current velocity of the NavMeshAgent component, or set a velocity to control the agent manually.
agent = agentobject.NavMeshAgent
if agent == nil then
agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
function OutputVelocity()
Space.Log("Velocity is : " .. agent.Velocity.ToString())
end
agentobject.SubscribeToEvents()
agentobject.OnUpdate(OutputRemainingDistance)
--register update events to navmesh agent's game object
agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition
|