So I am creating a 3D PAC-Man like FPS but there is a problem with the scripting, I cannot find a way to make a ghost follow some way-points but then when is close start following the player and then go back to following the way-points, I haven’t scripted anything this complex in a while, so if you could give the code for it, that would be much appreciated. C# is okay but JS is preferred. Thanks in advance!
If you want waypoints then I have a simple solution. Just create 2 empty gameObjects, and in the script create a public Transform array, and then go for the Vector3(or 2).MoveTowards so and so point. Create an object reference for the points. If you are confused just tell me.
Behaviour Tree is the appropriate tool to define such AI.
Have a look at Panda BT (www.pandabehaviour.com), it’s a script-based Behaviour Tree framework. The package contains examples demonstrating patrolling-chasing-attacking behaviours.
If you have any question about using this tool, you’re welcome on this thread.