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)
|