Tutorial [Rm2k3 TUTORIAL] How to make an enemy move toward an object that is not the hero (Read 259 times)

  • Avatar of nickmasterx
  • Pip
  • Group: Member
  • Joined: Jul 18, 2006
  • Posts: 164
I thought I'd share this, since A) I'm bored waiting for my class to start and B) It was a neat idea I thought of.
For example,
I was making a dodgeball minigame in my game Aptos Adventures II.
You can use this for anything where a character has to walk to something besides the hero,
sort of like pathfinding made easy.
In order for the enemy to walk up to the ball, I had to do this:

Make a parallel process event and set up X and Y variables of the sprite for the ball and then ones for the enemy.
Make another parallel process event (this can be another page on the enemy event)
Condition- If Ball X >
Enemy X: Move enemy Right
Wait .2 seconds

If Ball X < enemy X: move left
wait .2 seconds

If  Ball Y < Enemy Y: Move up
Wait .2 seconds

If Ball Y > Enemy Y: Move down

If Ball X= enemy X and
Ball Y= Enemy Y

Move event- enemy- change GFX to sprite w/ ball
(then make him move toward the hero and throw the ball or something)

That's just a small example, but I hope you guys can find that useful.
The dodgeball game is only in a short section of my game, but
check it out when I release the next demo.
Last Edit: April 27, 2010, 12:24:44 am by nickmasterx