SNavMeshAgent
在此类中GetAreaCost
- 函数
- Get
Area Cost - Move
- Resume
- Set
Area Cost - Stop
- Set
Destination - Warp
- 属性
- Enabled
- Accelleration
- Angular
Speed - Area
Mask - Auto
Repath - Auto
Braking - Auto
Traverse Off Mesh Link - Avoidance
Priority - Base
Offset - Desired
Velocity - Destination
- Has
Path - Height
- Is
On Nav Mesh - Is
On Off Mesh Link - Is
Path Stale - Next
Position - Path
End Position - Path
Pending - Radius
- Remaining
Distance - Speed
- Steering
Target - Stopping
Distance - Update
Position - Update
Rotation - Velocity
- Game
Object
| 函数 | GetAreaCost | – |
| 函数 | Move | Apply relative movement to current position. |
| 函数 | Resume | Resume the NavMesh agent. |
| 函数 | SetAreaCost | Sets the cost for traversing over areas of the area type. |
| 函数 | Stop | To stop the NavMesh agent. |
| 函数 | SetDestination | Set or update the destination. |
| 函数 | Warp | Warp to the position you want, also you can set agent's world position and vector to make this act as Move(SVector position). |
| 属性 | Enabled | Enable or disable this component. |
| 属性 | Accelleration | The maximum acceleration of an agent as it follows a path. |
| 属性 | AngularSpeed | Maximum turning speed in while following a path. |
| 属性 | AreaMask | Specifies which NavMesh area is passable. |
| 属性 | AutoRepath | Set the agent attempt to acquire a new path if the existing path becomes invalid. |
| 属性 | AutoBraking | Set the agent brake automatically to avoid overshooting the destination point. |
| 属性 | AutoTraverseOffMeshLink | Set the agent move across OffMeshLinks automatically. |
| 属性 | AvoidancePriority | The avoidance priority level. |
| 属性 | BaseOffset | The relative vertical displacement of the GameObject. |
| 属性 | DesiredVelocity | The desired velocity of the agent including any potential contribution from avoidance. |
| 属性 | Destination | The desired velocity of the agent including any potential contribution from avoidance. |
| 属性 | HasPath | Does the agent currently have a path? |
| 属性 | Height | The height of the agent for purposes of passing under obstacles, etc. |
| 属性 | IsOnNavMesh | Is the agent currently bound to the navmesh? |
| 属性 | IsOnOffMeshLink | Is the agent currently positioned on an OffMeshLink? |
| 属性 | IsPathStale | Is the current path stale? |
| 属性 | NextPosition | Get or set the simulation position of the navmesh agent. |
| 属性 | PathEndPosition | End positon of navigation. |
| 属性 | PathPending | Is a path in the process of being computed but not yet ready? |
| 属性 | Radius | The avoidance radius for the agent. |
| 属性 | RemainingDistance | The distance between the agent's position and the destination on the current path. |
| 属性 | Speed | Maximum movement speed when following a path. |
| 属性 | SteeringTarget | Get the current steering target along the path. |
| 属性 | StoppingDistance | Stop within this distance from the target position. |
| 属性 | UpdatePosition | Get or set whether the transform position is synchronized with the simulated agent position. |
| 属性 | UpdateRotation | Should the agent update the transform orientation? |
| 属性 | Velocity | access the current velocity of the NavMeshAgent component, or set a velocity to control the agent manually. |
| 属性 | GameObject | – |
函数
GetAreaCost
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| areaIndex | int | – |
返回值
float
示例
floatCost = Space.Host.ExecutingObject.NavMeshAgent.GetAreaCost(1)
Move
Apply relative movement to current position.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| movement | SVector | – |
返回值
void
示例
Space.Host.ExecutingObject.NavMeshAgent.Move(Vector.New(2,0,0))
Resume
Resume the NavMesh agent.
返回值
void
示例
Space.Host.ExecutingObject.NavMeshAgent.Resume()
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
Sets the cost for traversing over areas of the area type.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| areaIndex | int | – |
| cost | float | – |
返回值
void
示例
Space.Host.ExecutingObject.NavMeshAgent.SetAreaCost(1, 10.0)
Stop
To stop the NavMesh agent.
返回值
void
示例
Space.Host.ExecutingObject.NavMeshAgent.Stop()
SetDestination
Set or update the destination.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| position | SVector | – |
返回值
void
示例
Space.Host.ExecutingObject.NavMeshAgent.SetDestination(Vector.New(10,0,0))
Warp
Warp to the position you want, also you can set agent's world position and vector to make this act as Move(SVector position).
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| position | SVector | – |
返回值
void
示例
Space.Host.ExecutingObject.NavMeshAgent.Warp(Vector.New(10,0,0))
属性
Enabled
Enable or disable this component.
示例
Space.Host.ExecutingObject.NavMeshAgent.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)
Accelleration
The maximum acceleration of an agent as it follows a path.
示例
Space.Host.ExecutingObject.NavMeshAgent.Accelleration = 60
AngularSpeed
Maximum turning speed in while following a path.
示例
Space.Host.ExecutingObject.NavMeshAgent.AngularSpeed = 60
AreaMask
Specifies which NavMesh area is passable.
示例
Space.Host.ExecutingObject.NavMeshAgent.AreaMask = 3
AutoRepath
Set the agent attempt to acquire a new path if the existing path becomes invalid.
示例
Space.Host.ExecutingObject.NavMeshAgent.AutoRepath = false
AutoBraking
Set the agent brake automatically to avoid overshooting the destination point.
示例
Space.Host.ExecutingObject.NavMeshAgent.AutoBraking = false
AutoTraverseOffMeshLink
Set the agent move across OffMeshLinks automatically.
示例
Space.Host.ExecutingObject.NavMeshAgent.AutoTraverseOffMeshLink = false
AvoidancePriority
The avoidance priority level.
示例
Space.Host.ExecutingObject.NavMeshAgent.AvoidancePriority = 10
BaseOffset
The relative vertical displacement of the GameObject.
示例
Space.Host.ExecutingObject.NavMeshAgent.BaseOffset = 3
DesiredVelocity只读
The desired velocity of the agent including any potential contribution from avoidance.
示例
vectorVelocity = Space.Host.ExecutingObject.NavMeshAgent.DesiredVelocity
Destination
The desired velocity of the agent including any potential contribution from avoidance.
示例
Space.Host.ExecutingObject.NavMeshAgent.Destination = Vector.New(10,0,0)
HasPath只读
Does the agent currently have a path?
示例
hasPath = Space.Host.ExecutingObject.NavMeshAgent.HasPath
Height
The height of the agent for purposes of passing under obstacles, etc.
示例
Space.Host.ExecutingObject.NavMeshAgent.Height = 5
IsOnNavMesh只读
Is the agent currently bound to the navmesh?
示例
isOn = Space.Host.ExecutingObject.NavMeshAgent.IsOnNavMesh
IsOnOffMeshLink只读
Is the agent currently positioned on an OffMeshLink?
示例
isOnOff = Space.Host.ExecutingObject.NavMeshAgent.IsOnOffMeshLink
IsPathStale只读
Is the current path stale?
示例
isStale = Space.Host.ExecutingObject.NavMeshAgent.IsPathStale
NextPosition
Get or set the simulation position of the navmesh agent.
示例
Space.Host.ExecutingObject.NavMeshAgent.NextPosition = Vector.New(10, 0, 0)
PathEndPosition只读
End positon of navigation.
示例
vectorPathEndPos = Space.Host.ExecutingObject.NavMeshAgent.PathEndPosition
PathPending只读
Is a path in the process of being computed but not yet ready?
示例
isPending = Space.Host.ExecutingObject.NavMeshAgent.PathPending
Radius
The avoidance radius for the agent.
示例
Space.Host.ExecutingObject.NavMeshAgent.Radius = 5
RemainingDistance只读
The distance between the agent's position and the destination on the current path.
示例
vectorDist = Space.Host.ExecutingObject.NavMeshAgent.RemainingDistance
Speed
Maximum movement speed when following a path.
示例
Space.Host.ExecutingObject.NavMeshAgent.Speed = 20
SteeringTarget只读
Get the current steering target along the path.
示例
vectorSteeringTarget = Space.Host.ExecutingObject.NavMeshAgent.SteeringTarget
StoppingDistance
Stop within this distance from the target position.
示例
Space.Host.ExecutingObject.NavMeshAgent.StoppingDistance = 2
UpdatePosition
Get or set whether the transform position is synchronized with the simulated agent position.
示例
Space.Host.ExecutingObject.NavMeshAgent.UpdatePosition = true
UpdateRotation
Should the agent update the transform orientation?
示例
Space.Host.ExecutingObject.NavMeshAgent.UpdateRotation = true
Velocity只读
access the current velocity of the NavMeshAgent component, or set a velocity to control the agent manually.
示例
vectorVelocity = Space.Host.ExecutingObject.NavMeshAgent.Velocity
GameObject只读
示例
theGameObject = Space.Host.ExecutingObject.NavMeshAgent.GameObject



