Unity 3D Game Engine – Pathfinding – Offmesh Links

With Offmesh Links you can link two or more NavMesh.

1. Create EmptyObject, name it ‘targetNavigation’

2. Create a Sphere, name it ‘enemy’ with:
– NavMeshAgent
– SimpleAgentScript.js

SimpleAgentScript.js:


#pragma strict


    public var target : Transform; // inside Inspector assign the Target object
	private var agent: NavMeshAgent;
	
	function Start () {
		agent = GetComponent.<NavMeshAgent>();
	}
	function Update () {

				agent.SetDestination(target.position);
					
	}

Inspector> DRAG AND DROP over variable Target the ‘targetNavigation’ object

Automatic

3. Create 2 Box

4. Select the 2 Box (CTRL+LMB)>

> Navigation> Object> check OffMeshLink Generation

> Navigation> Bake> Generated Off Mesh Links>

– Jump Distance = 10 (maximum agent jump distance)

– Drop Height = 10 (maximum agent drop height)

> Bake

Manually

3. Create 2 Box, name it ‘start’ and ‘end’

4. Select the 2 Box (CTRL+LMB)>

> Navigation> Object> uncheck OffMeshLink Generation

> Navigation> Bake> Generated Off Mesh Links>

– Jump Distance = 10 (maximum agent jump distance)

– Drop Height = 10 (maximum agent drop height)

> Bake

4. Inspector> Select ‘start’> ‘Add Component’> Navigation> OffMesh Links>

OffMesh Link> Hierarchy

– DRAG AND DROP ‘start’ game object over public variable ‘Start’

– DRAG AND DROP ‘end’ game object over public variable ‘End’

> you do not need to re-Bake

The Character not jumping!

Try to re-setup Navigation> Bake> General> – Height
– Step Height