Effect:
Using layered road navigation to make the characters take different navigation routes
1. Create a static map
2. Set 3 different layers
3. Set different navigation layers for different pavements.
4, in the navigation components to set the role area Mask, set the role can go to which layer
1) Set Char_ethan cannot go to SAP (down road), middle (middle) layer
2) Set Sapphiartchan cannot go char (on the road), middle (middle) layer
5. Add scripts to Sapphiartchan and Char_ethan:
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityengine;usingUnityengine.ai; Public classNavigationtest:monobehaviour {PrivateAnimator Animator;//Walking Animation PrivateNavmeshagent agent;//Navigation Components PrivateTransform Target;//Target Location voidStart () {animator= getcomponent<animator>(); Agent= getcomponent<navmeshagent>(); Target= Gameobject.find ("Target"). Transform; }voidUpdate () {if(Input.getkeydown (Keycode.space))//Press SPACE Bar{Agent.} Setdestination (target.position); //Start Navigationanimator. Setbool ("Walk",true);//Walking Animation Open } if(Vector3.distance (target.position,transform.position) <=1.5f)//if you reach target 1.5m{agent.isstopped=true;//Endanimator. Setbool ("Walk",false);//End of Walk }}}
Unity (iii) Navmeshagent: Layered Road Navigation (King Glory, League of Legends Small soldiers divided three ways to attack the enemy)