I apologize if this question has been asked 1000 times before. I couldn’t find an answer to it.
Once a path has been created, how do you stop it before the character reaches the destination? I’ve tried to make the path null based on a left click just for testing but it simply threw a null reference exception. Then I tried to set the waypoint distance variable I created to 1000 but that failed too. Indeed I have tried many totally ineffective strategies.
My game is a 3D isometric RTS. Units are controlled via mouse clicks. There are situations when I will need to cancel a path and stop the character short without simply changing the path with another right click.
Any advice or direction to relevant resources would be most appreciated.
The absolute easiest way which works regardless of movement script is just to simulate a new movement order but to the character’s current position, that will effectively stop it.
If you are using the AIPath script you can set canMove to “false”.
Hi Aron, While this work great is there also a way to remove the path once canMove is set to false? I am asking because on re enabling this the path is still there. I am accessing it from another main script on the same object to avoid editing the orginal AIPath script. Here is my code gameObject.GetComponent<AIPath>().canMove = false;