Call Astar script from my own script

Hi guys,

I’m currently working on a 2D top down shooting game.
I already built a script to control ennemies, so they are able to shoot the player if the player is in a certain range. If the player is out of this range, the ennemies are just patrolling.

I want to add the Astar script because if the player is in a house, I want that the ennemy come in this house to search the player.

Thus, I want to call Astar script in certain condition (I know what are my conditions) but I don’t know how to call it.

Could you help me please ?
Thanks !

Hi

It sounds like you want to communicate with the movement script (e.g AIPath or AILerp). You can do this by simply calling

var ai = GetComponent<AIPath>();

or

var ai = GetComponent<AILerp>();

Then you can modify e.g the destination, if the ai should stop, and a lot of other things. See the documentation for more info.