wiki.sine.space | sinespace

Scripting/SNavMeshObstacle

From wiki.sine.space
Revision as of 02:44, 23 December 2020 by Edisonwu (Talk | contribs) (Created page with "The NavMeshObstacle allows users to describe moving obstacles that NavMeshAgents should avoid while navigating the world. =Properties= {{ScriptFunction|SVector|Center|{get...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The NavMeshObstacle allows users to describe moving obstacles that NavMeshAgents should avoid while navigating the world.


Properties

Center

SVector Center {get; set;}

Center of the obstacle geometry relative to the transform position.

agentobject = Space.Scene.Find("Cube")

agent = agentobject.NavMeshAgent
if agent == nil then
    agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
navobstacle = Space.Scene.Find("Obstacle")
--get obstacle component.
obstacle = navobstacle.NavMeshObstacle
obstacle.Center = Vector.New(1,1,1)
Space.Log(obstacle.Center.ToString())

--set geometry to 1,1,1 .


Height

float Height {get; set;}

Height of the capsule. (Property of Capsule shape).

agentobject = Space.Scene.Find("Cube")

agent = agentobject.NavMeshAgent
if agent == nil then
    agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
navobstacle = Space.Scene.Find("Obstacle")
--get obstacle component.
obstacle = navobstacle.NavMeshObstacle
obstacle.Shape = 0
obstacle.Height = 40
Space.Log(obstacle.Height)

--set shape to capsule and set height to 40.


Size

SVector Size {get; set;}

Size of the box. (Property of Box shape).

agentobject = Space.Scene.Find("Cube")

agent = agentobject.NavMeshAgent
if agent == nil then
    agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
navobstacle = Space.Scene.Find("Obstacle")
--get obstacle component.
obstacle = navobstacle.NavMeshObstacle
obstacle.Shape = 1
obstacle.Size = Vector.New(5,10,15)

--set shape to box and set length, width, height to 5,10,15.


Carving

bool Carving {get; set;}

When the Carve checkbox gets ticked, the Nav Mesh Obstacle creates a hole in the NavMesh.

agentobject = Space.Scene.Find("Cube")

agent = agentobject.NavMeshAgent
if agent == nil then
    agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
navobstacle = Space.Scene.Find("Obstacle")
--get obstacle component.
obstacle = navobstacle.NavMeshObstacle
obstacle.Carving = true
Space.Log(obstacle.Carving)

--enable carving and return the status of it.


MoveThreshold

float MoveThreshold {get; set;}

Use this property to set the threshold distance for updating a moving carved hole. (Only can take effect after carve was ticked)


agentobject = Space.Scene.Find("Cube")

agent = agentobject.NavMeshAgent
if agent == nil then
    agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
navobstacle = Space.Scene.Find("Obstacle")
--get obstacle component.
obstacle = navobstacle.NavMeshObstacle
obstacle.Carving = true
obstacle.MoveThreshold = 5

--set move threshold to 5.


TimeToStationary

float TimeToStationary {get; set;}
The time to wait until the obstacle is treated as stationary. (Only can take effect after carve was ticked).


agentobject = Space.Scene.Find("Cube")

agent = agentobject.NavMeshAgent
if agent == nil then
    agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
navobstacle = Space.Scene.Find("Obstacle")
--get obstacle component.
obstacle = navobstacle.NavMeshObstacle
obstacle.Carving = true
obstacle.TimeToStationary = 5

--set time to stationary to 5.


CarveOnlyStationary

bool CarveOnlyStationary {get; set;}
When enabled, the obstacle is carved only when it is stationary. (Only can enabled after carve was ticked).


agentobject = Space.Scene.Find("Cube")

agent = agentobject.NavMeshAgent
if agent == nil then
    agent = Space.Scene.Find("Cube").AddNavMeshAgent()
end
navobstacle = Space.Scene.Find("Obstacle")
--get obstacle component.
obstacle = navobstacle.NavMeshObstacle
obstacle.Carving = true
obstacle.CarveOnlyStationary = false

--disable carve only stationary.