I can't seem to find any tutorials on how to make monsters move or patrol or have movements routines.
Nothing fancy, something like:
Go from A to B, wait a few frames, go to C, wait again, go back to A and repeat.
The monster doesn't even have to notice the player, just walk its path.
I've tried with loops but I can't make it work.
Thank you very much!!! :D
What have you considered so far?
One simple approach:
Store the positions for each monster: Its current position, plus a table with all the stops in the patrol, and finally a variable that just holds the index in the stop table that contains the current goal.
Then, each frame, make the monster's current position closer to the goal. If it reaches the goal, increment the goal variable so the next stop becomes the goal. (Use the modulo operator % to wrap around to the first stop again when it has reached the last one.)
Of course, how you make the monster move towards the goal is the tricky part. Do you need a path finding algorithm (like A*)? There are lots of different possible approaches here.
[Please log in to post a comment]