How to make wandering 2D Enemies?

So, how could I make the enemy (Purple slime in this image) WANDER from left to right without falling off the cliff?
By wander i mean i don't want it to move left to right etc. like a goomba, but instead to move a few pixels left or right, from time to time.
Any help is appreciated, FM.
Best Answer
-
Braydon_SFX Posts: 9,273
Maybe put a random timer, in that timer put a interpolate self position x to whatever. This should get you going.
Answers
Let's say you want to constrain the slime to an x value between 200 and 280. Constrain attribute self.position.x to max(200,min(self.position.x,280)).
Here's a demo: http://dl.dropbox.com/u/19602014/Random sideways movement.zip