A* Pathfinding Project

How to enable/disable movement from another script?


#1

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


#2

Hey,

If you are using one of the IAStarAI based movement scripts, you can use the IsStopped property.
https://arongranberg.com/astar/docs/old/interface_pathfinding_1_1_i_astar_a_i.php#a395c23c8af16726f8a5abddd2f3bd198


#3

@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


#4

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?


#5

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


#6

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?


#7

Hi

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.


#8

I’ll check it out, thanks.