(Created page with "Navigation mesh agent. is attached to a mobile character in the game to allow it to navigate the Scene using the NavMesh. =Members= {{ScriptFunction|void|Move|(SVector mov...") |
|||
Line 72: | Line 72: | ||
agent.Wrap(Vector.New(2,0,0)+agent.GameObject.WorldPosition)<br> | agent.Wrap(Vector.New(2,0,0)+agent.GameObject.WorldPosition)<br> | ||
'' --Wrap forward 2 meters.'' | '' --Wrap forward 2 meters.'' | ||
+ | }} | ||
+ | |||
+ | =Properties= | ||
+ | {{ScriptFunction|bool|Enabled|{get; set;}|Enable or disable this component.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Enabled = false<br> | ||
+ | '' --disable navmesh agent.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|Accelleration|{get; set;}|The maximum acceleration of an agent as it follows a path.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Accelleration = 60<br> | ||
+ | '' --set accellratioon to 60.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|Accelleration|{get; set;}|The maximum acceleration of an agent as it follows a path.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Accelleration = 60<br> | ||
+ | '' --set accellratioon to 60.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|AngularSpeed|{get; set;}|Maximum turning speed in while following a path.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.AngularSpeed = 60<br> | ||
+ | '' --set AngularSpeed to 60.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|int|AreaMask|{get; set;}| Specifies which NavMesh area is passable.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.AreaMask = 3<br> | ||
+ | '' --set AreaMask to layer1 and layer2.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|AutoRepath|{get; set;}| Set the agent attempt to acquire a new path if the existing path becomes invalid.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.AutoRepath = false<br> | ||
+ | ''--set AutoRepath false.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|AutoBraking|{get; set;}| Set the agent brake automatically to avoid overshooting the destination point.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.AutoBraking = false<br> | ||
+ | ''--set AutoBraking false.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|AutoTraverseOffMeshLink|{get; set;}| Set the agent move across OffMeshLinks automatically.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.AutoTraverseOffMeshLink = false<br> | ||
+ | ''--set AutoTraverseOffMeshLink false.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|int|AvoidancePriority|{get; set;}|The avoidance priority level.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.AvoidancePriority = 60<br> | ||
+ | ''--set AvoidancePriority to 60.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|BaseOffset|{get; set;}|The relative vertical displacement of the GameObject.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.BaseOffset = 3<br> | ||
+ | ''--set BaseOffset to 3.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SVector|DesiredVelocity|{get;}| The desired velocity of the agent including any potential contribution from avoidance.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | Space.Log(agent.DesiredVelocity.ToString())<br> | ||
+ | ''--output the desired velocity.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SVector|Destination|{get; set;}| The desired velocity of the agent including any potential contribution from avoidance.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination for target transforming.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|HasPath|{get;}|Does the agent currently have a path?|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | Space.Log(agent.HasPath)<br> | ||
+ | ''--Return has path or not.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|Height|{get; set;}|The height of the agent for purposes of passing under obstacles, etc.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Height = 60<br> | ||
+ | '' --set height to 60.'' | ||
+ | }} | ||
+ | |||
+ | |||
+ | {{ScriptFunction|bool|IsOnNavMesh|{get;}|Is the agent currently bound to the navmesh?|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | Space.Log(agent.IsOnNavMesh)<br> | ||
+ | ''--output this agent is on the navmesh.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|IsOnOffMeshLink|{get;}| Is the agent currently positioned on an OffMeshLink?|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | Space.Log(agent.IsOnOffMeshLink)<br> | ||
+ | ''--output this agent is on off meshlink.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|IsPathStale|{get;}|Is the current path stale?|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | Space.Log(agent.IsPathStale)<br> | ||
+ | ''--output the path is stale.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SVector|NextPosition|{get; set;}|Get or set the simulation position of the navmesh agent.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | function OutputNextPosition()<br> | ||
+ | Space.Log(agent.NextPosition)<br> | ||
+ | end<br> | ||
+ | agentobject.SubscribeToEvents()<br> | ||
+ | agentobject.OnUpdate(OutputNextPosition)<br> | ||
+ | ''--register update events to navmesh agent's game object''<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SVector|PathEndPosition|{get;}|End positon of navigation.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | Space.Log(agent.PatchEndPosition)<br> | ||
+ | ''--output the end position of the navmesh agent.'' | ||
+ | }} | ||
+ | |||
+ | |||
+ | {{ScriptFunction|bool|PathPending|{get;}|Is a path in the process of being computed but not yet ready?|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | function OutputPathPending()<br> | ||
+ | Space.Log(agent.PathPending)<br> | ||
+ | end<br> | ||
+ | agentobject.SubscribeToEvents()<br> | ||
+ | agentobject.OnUpdate(OutputPathPending)<br> | ||
+ | ''--register update events to navmesh agent's game object''<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|Radius|{get; set;}|The avoidance radius for the agent.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Radius = 5<br> | ||
+ | ''--set radius of agent to 5.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|RemainingDistance|{get;}|The distance between the agent's position and the destination on the current path.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | function OutputRemainingDistance()<br> | ||
+ | Space.Log(agent.RemainingDistance)<br> | ||
+ | end<br> | ||
+ | agentobject.SubscribeToEvents()<br> | ||
+ | agentobject.OnUpdate(OutputRemainingDistance)<br> | ||
+ | ''--register update events to navmesh agent's game object''<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|Speed|{get; set;}|Maximum movement speed when following a path.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Speed = 20<br> | ||
+ | ''--set speed to 20.''<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SVector|SteeringTarget|{get;}|Get the current steering target along the path.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.''<br> | ||
+ | Space.Log(agent.SteeringTarget.ToString())<br> | ||
+ | ''--output steering target position.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|float|StoppingDistance|{get; set;}|Stop within this distance from the target position.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.StoppingDistance = 2<br> | ||
+ | ''--set stopping distance.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|UpdatePosition|{get; set;}Get or set whether the transform position is synchronized with the simulated agent position.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.UpdatePosition = false<br> | ||
+ | ''--set update position to false.''<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|UpdatePosition|{get; set;}Should the agent update the transform orientation?|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | agent.UpdateRotation = false<br> | ||
+ | ''--set update Rotation to false.''<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SVector|Velocity|{get;}|access the current velocity of the NavMeshAgent component, or set a velocity to control the agent manually.|5=agentobject = Space.Scene.Find("Cube")<br> | ||
+ | agent = agentobject.NavMeshAgent<br> | ||
+ | if agent == nil then<br> | ||
+ | agent = Space.Scene.Find("Cube").AddNavMeshAgent()<br> | ||
+ | end<br> | ||
+ | function OutputVelocity()<br> | ||
+ | Space.Log("Velocity is : " .. agent.Velocity.ToString())<br> | ||
+ | end<br> | ||
+ | agentobject.SubscribeToEvents()<br> | ||
+ | agentobject.OnUpdate(OutputRemainingDistance)<br> | ||
+ | ''--register update events to navmesh agent's game object''<br> | ||
+ | agent.Destination = Space.Scene.Find("TargetTransform").WorldPosition<br> | ||
+ | ''--set destination.'' | ||
}} | }} | ||
{{Scripting Navbox}} | {{Scripting Navbox}} |
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
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
|