Multi-Floor, Levels pathfinding with Navmesh
Hello,
I'm working on a project on the unity 5.6.1 to draw the path between two Gameobjects on the different floors (Levels). in my project I have just two levels. I have used the Sketchup to create my model with two floors and staircase (stair)to connect them together =>export Dae extension.
On the Unity, I'm using Unity's built-in pathfinding engine, i build a Navmesh for the first floor, stair and second floor. I put the different Gameobjects on the scene, with the color blue and orange, the oranges are the origin and the blue is the destination. i have attached LineRender and NavmeshAgent to origin Gameobject, when i try to draw the path between two Gameobjects on the different floor i have achieved these results:
Origin(Orange color) on the first floor and the destination(blue color) on the second(the path is not across the stair:
Another problem, two GameObjects on the same floor(Second floor).the path is not correctly drawn.
It's work correctly, when the destination GameObject is on the first floor.
Idon't know what is the problem, can you help me to find the problem please ? Thank you for taking your time reading my question.
void Update()
{
//Get the postion one of the orange's gameobjet on the scene,
and set it to origin gameobject(attached lineRenderer, NavmeshAgent
and the script to it)
//Cube -> First floor , Cube(1) --> first floor,
//Cube(2) --> second floor
this.transform.position= GameObject.Find("Cube").transform.position;
OnDrawGiz(GameObject.Find("Destination"));
}//end update
void OnDrawGiz(GameObject obj)
{
//Destroy GameObjects
Transform target =
obj.GetComponent<Transform> ();
NavMeshAgent nav;
LineRenderer line;
nav= this.GetComponent<NavMeshAgent>();
if( nav == null || nav.path == null )
return;
line = this.GetComponent<LineRenderer>();
line.material = new Material( Shader.Find( "Sprites/Default" ) ) { color = Color.yellow };
line.startColor=Color.yellow;
line.endColor = Color.green;
nav.SetDestination (target.position);
//nav.isStopped=true;
var path = nav.path;
if (path.corners.Length < 2)
return ;
line.positionCount=path.corners.Length ;
//line.alignment = LineAlignment.Local;
//Draw the line
for( int i = 0; i < path.corners.Length; i++ )
{
line.SetPosition( i, path.corners[i] );
}
}
}
Answer by mokabiri · Jul 11, 2017 at 09:45 AM
The Navmesh Configuration in my project :
Answer by Toddweiss · Sep 04, 2019 at 03:23 AM
Does anyone have a solution for this??? is this solved?