Breakroom is now Sinewave Campus. Book a meeting

SNavMeshAgent

客户端组件
在此类中GetAreaCost
  1. 函数
  2. GetAreaCost
  3. Move
  4. Resume
  5. SetAreaCost
  6. Stop
  7. SetDestination
  8. Warp
  9. 属性
  10. Enabled
  11. Accelleration
  12. AngularSpeed
  13. AreaMask
  14. AutoRepath
  15. AutoBraking
  16. AutoTraverseOffMeshLink
  17. AvoidancePriority
  18. BaseOffset
  19. DesiredVelocity
  20. Destination
  21. HasPath
  22. Height
  23. IsOnNavMesh
  24. IsOnOffMeshLink
  25. IsPathStale
  26. NextPosition
  27. PathEndPosition
  28. PathPending
  29. Radius
  30. RemainingDistance
  31. Speed
  32. SteeringTarget
  33. StoppingDistance
  34. UpdatePosition
  35. UpdateRotation
  36. Velocity
  37. GameObject
成员 35
函数GetAreaCost–
函数MoveApply relative movement to current position.
函数ResumeResume the NavMesh agent.
函数SetAreaCostSets the cost for traversing over areas of the area type.
函数StopTo stop the NavMesh agent.
函数SetDestinationSet or update the destination.
函数WarpWarp to the position you want, also you can set agent's world position and vector to make this act as Move(SVector position).
属性EnabledEnable or disable this component.
属性AccellerationThe maximum acceleration of an agent as it follows a path.
属性AngularSpeedMaximum turning speed in while following a path.
属性AreaMaskSpecifies which NavMesh area is passable.
属性AutoRepathSet the agent attempt to acquire a new path if the existing path becomes invalid.
属性AutoBrakingSet the agent brake automatically to avoid overshooting the destination point.
属性AutoTraverseOffMeshLinkSet the agent move across OffMeshLinks automatically.
属性AvoidancePriorityThe avoidance priority level.
属性BaseOffsetThe relative vertical displacement of the GameObject.
属性DesiredVelocityThe desired velocity of the agent including any potential contribution from avoidance.
属性DestinationThe desired velocity of the agent including any potential contribution from avoidance.
属性HasPathDoes the agent currently have a path?
属性HeightThe height of the agent for purposes of passing under obstacles, etc.
属性IsOnNavMeshIs the agent currently bound to the navmesh?
属性IsOnOffMeshLinkIs the agent currently positioned on an OffMeshLink?
属性IsPathStaleIs the current path stale?
属性NextPositionGet or set the simulation position of the navmesh agent.
属性PathEndPositionEnd positon of navigation.
属性PathPendingIs a path in the process of being computed but not yet ready?
属性RadiusThe avoidance radius for the agent.
属性RemainingDistanceThe distance between the agent's position and the destination on the current path.
属性SpeedMaximum movement speed when following a path.
属性SteeringTargetGet the current steering target along the path.
属性StoppingDistanceStop within this distance from the target position.
属性UpdatePositionGet or set whether the transform position is synchronized with the simulated agent position.
属性UpdateRotationShould the agent update the transform orientation?
属性Velocityaccess the current velocity of the NavMeshAgent component, or set a velocity to control the agent manually.
属性GameObject–

函数​

GetAreaCost​

float GetAreaCost(int areaIndex)

参数

名称类型默认值
areaIndexint–

返回值

float

示例

Lua
floatCost = Space.Host.ExecutingObject.NavMeshAgent.GetAreaCost(1)

Move​

void Move(SVector movement)

Apply relative movement to current position.

参数

名称类型默认值
movementSVector–

返回值

void

示例

Lua
Space.Host.ExecutingObject.NavMeshAgent.Move(Vector.New(2,0,0))

Resume​

void Resume()

Resume the NavMesh agent.

返回值

void

示例

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.

参数

名称类型默认值
areaIndexint–
costfloat–

返回值

void

示例

Lua
Space.Host.ExecutingObject.NavMeshAgent.SetAreaCost(1, 10.0)

Stop​

void Stop()

To stop the NavMesh agent.

返回值

void

示例

Lua
Space.Host.ExecutingObject.NavMeshAgent.Stop()

SetDestination​

void SetDestination(SVector position)

Set or update the destination.

参数

名称类型默认值
positionSVector–

返回值

void

示例

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

参数

名称类型默认值
positionSVector–

返回值

void

示例

Lua
Space.Host.ExecutingObject.NavMeshAgent.Warp(Vector.New(10,0,0))

属性​

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
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
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; }

示例

Lua
theGameObject = Space.Host.ExecutingObject.NavMeshAgent.GameObject