I'm working on a game in which I need a set of enemies to walk around on set paths but randomly, like the ghosts on Pacman. What is the best way to set up a simple 4 direction movement like this?
You could have the enemies have sensors on 4 sides, and if the side sensors are on a wall, just move up and down, same with top and bottom sensors. Change direction randomly based on the sensors. Shouldn't be to hard.
I wouldn't use the pathmovement for that. I'd just do a custom movement, or maybe even the bounce movement with only 4 directions, when it touches those sensors like brandon said, pick a random direction out of those 4.
Thanks for your suggestions. I have a few questions though. I had initially tried using the bounce method but when setting up the angles the lowest setting is 8, and I obviously want only 4. This may not be the cause of my problems, but my enemies are always getting off track inside the paths they are in, as they aren't as wide as the paths themselves. Also, when you say "custom movement", what all does that entail? I'm obviously pretty new at this so all your help is greatly appreciated.
Fixing the problem with enemies not being as wide as the paths is easy, just move the sensors out farther from the enemy, if that doesn't work. Make the enemies bigger.
Yeah, that's definitely what I need to do if I'm going the sensor route, but my paths aren't all exactly the same size, which makes things more difficult. If all else fails, I guess I can go back and adjust my paths to be perfectly sized, but hopefully I can find another method of keeping them from bouncing around.
I made a quick example of a grid-based enemy AI
http://rapidshare.de/files/27450621/grimovement.zip.html
This movement uses no detectors and works with multiple enemies
This is an MMF example, but since it only uses 1 active object it could easily be converted to TGF if needed, i just don't have TGF on this computer...