Unity pathfinding Empty object A Astar Path component
Unity pathfinding
• Empty object (A*) • "Astar. Path" component: Components Pathfi nding Pathfinder • Collision testing: obstacles • Height testing: ground • Scan!
Astar. AI. cs using Unity. Engine; using System. Collections; //Note this line, if it is left out, the script won't know that the class 'Path' exists and it will throw compiler errors //This line should always be present at the top of scripts which use pathfinding using Pathfinding; public class Astar. AI : Mono. Behaviour { public Vector 3 target. Position; public void Start () { //Get a reference to the Seeker component we added earlier Seeker seeker = Get. Component<Seeker>(); //Start a new path to the target. Position, return the result to the On. Path. Complete function seeker. Start. Path (transform. position, target. Position, On. Path. Complete); } } public void On. Path. Complete (Path p) { Debug. Log ("Yay, we got a path back. Did it have an error? "+p. error); }
- Slides: 6