Legacy Documentation: Version 5.0
Language: English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

public var size: Vector3;
public Vector3 size;

Description

The size of the obstacle, measured in the object's local space.

The size will be scaled by the transform's scale.

	// Fit a box shaped obstacle to the attached mesh

function Start () { var obstacle : NavMeshObstacle = GetComponent.<NavMeshObstacle>(); var mesh : Mesh = GetComponent.<MeshFilter>().mesh;

obstacle.shape = NavMeshObstacleShape.Box; obstacle.size = mesh.bounds.size; }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { NavMeshObstacle obstacle = GetComponent<NavMeshObstacle>(); Mesh mesh = GetComponent<MeshFilter>().mesh; obstacle.shape = NavMeshObstacleShape.Box; obstacle.size = mesh.bounds.size; } }