Pathfinding in Unity3d, you can use the Astarpath pathfinding plugin. It is now possible to use Unity's own Navigation functionality.
To do an example:
In the above picture, Cube is a block object, the ball is to represent the player, to find the way.
Set cube as a non-pass object
First we click on the Window-navigation window and then select 4 cubes, set these 4 cubes as not to pass, then bake
Set the ground to be passed, and then bake
We add control scripts to the Orb, our main character.
Using unityengine;using System.collections;public class Findpath:monobehaviour {public navmeshagent agent; Vector3 Point; Ray Aray; Raycasthit ahit;//Use the-initializationvoid Start () {}//Update is called once per framevoid update () {if (Input. Getmousebuttondown (0)) { Aray = Camera.main.ScreenPointToRay (input.mouseposition); if (Physics.raycast (aray,out ahit)) {point = Ahit.point; } Agent. Setdestination (point);}}}
Get the ball to the mouse click on the place to find the road effect
Unity3d pathfinding function Introduction and project demonstration