How to make wandering 2D Enemies?

FrazzleFrazzle Member Posts: 223
edited April 2012 in Working with GS (Mac)
image
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_SFXBraydon_SFX Posts: 9,273
    Accepted Answer
    Maybe put a random timer, in that timer put a interpolate self position x to whatever. This should get you going.

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2012
    Use a timer set to run at a random interval and then have another randomizer inside of the timer to pick a direction. Then use a Move behavior to move the slime in that direction.

    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
  • FrazzleFrazzle Member Posts: 223
    Thanks for the tips guys, am working on it.
Sign In or Register to comment.