[Platformer] A.I : Enemy follows and jump

  • 10 favourites

Attached Files

The following files have been attached to this tutorial:

Stats

4,563 visits, 5,965 views

Tools

In this tutorial im gonna teach you how to make an intelligent enemy that follows the player and automaticaly jump on obsacles.

Preparing the scene

You will need :

- The player sprite (Blue with a "J" on my tutorial)

- The enemy prite (Red with a "Z" on my tutorial)

- The ground (For the platformer)

- An obstacle

- A tilemap that looks like mine (Or download it) :

Then use their behaviours like this :

Player

Enemy

Use one platformer behaviour (I used 2 for the tutorial)

["NormalPlatform" is the original properties for the platformer behaviour, but use "ThisPlatform" for this tutorial]

Tilemap

Now import the Tilemap to use it as a zone where the enemy have to jump and change the collision box.

Make the layout

Now put the player, enemy, ground and obstacle on the layout and with the tilemap, use the red zones to show where the enemy will jump

Events

First, the enemy will follow the player :

"If the player is on the left from the enemy, make the enemy walk to the left"

"If the player is on the right from the enemy, make the enemy walk to the right"

Then we want the enemy to jump by himself, not when the platform behaviour wants him to do it :

It keeps the enemy active to jump but not to control

And now, the enemy will jump when he enters the "Jumping zone" in the tilemap :

For a moment, the enemy will stop ignoring to be active to jump, then we simulate the jump and automaticaly, with previous events, he will ignore again

Now you have a good A.I for a Platformer Enemy.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!