A* Pathfinding Project

How to enable/disable movement from another script?


I’m using seeker.StartPath to draw the path from another script, but how do I enable movement?



If you are using one of the IAStarAI based movement scripts, you can use the IsStopped property.


@unclepickle1 Movement is generally done using one of the built-in movement scripts or by writing your own movement script. Take a look at the get started tutorial for more info: https://arongranberg.com/astar/docs/getstarted.php


In your doc it says to use

transform.position += velocity * Time.deltaTime;

for 2D games, but the AI doesn’t follow the path this way. How can I make it follow the path in 2D?


I don’t understand your question. Could you elaborate a bit?


In the doc

`// If you are writing a 2D game you may want to remove the CharacterController and instead use e.g transform.Translate

// transform.position += velocity * Time.deltaTime;`

This makes the AI move directly towards the object instead of following the path. How do I enable/disable movement along the path from a script?



It would only move directly towards the target if your ‘pick next waypoint distance’ was set to a very high value. You can take a look at the example scenes for more help on how to configure an agent.


I’ll check it out, thanks.