Enemy which can jump on platforms etc

Is there a way to make an enemy able to jump on platforms, climbing stairs, avoiding water to follow the player?

I want to make a Platform game with these functions for enemies.
I tried to use the pathfinding behavior, but as I seen it can’t be used on platform games (top down games only).

I didn’t find something in the whole forum or youtube, is someone have suggestions or knows a way to make these things will be helpful for others in future for sure.

I have read that too but it seems that it is actually possible. The Gem Dev made a tutorial that uses the pathfinding behavior in a platformer and it seems to work quite okay:

It’s floating more than jumping, from the looks of it.
But I guess one could code proper jumps as well.

1 Like

Don´t know if this will help, but you could make some or all enemys be Plataformer Character Objects, have their default controlls deactivated and control them with your own simple AI System for having them avoid water and such things, is a longer code and probably is not the best for games with lots of enemys on screen.

I’ve seen this video too, but it doesn’t work properly when there are moving platforms

I was thinking about the same thing, by adding invisible sprites where the enemies can interact with. If they touch a jump sprite they’ll jump (i.e.), but as you said isn’t that good when there are 5-6 enemies at once.
I’m making a platform so there can be 5-6 enemies following the player

1 Like

I understand. I just wonder if enemies following the player across moving platforms would work very well at all. Moving platforms are often used as a kind of obstacle that requires the right timing and intuition. If you just let your enemies jump when they collide with a hidden sprite (which is probably the best way to do it), the chances are very high that they will fail.
You could give them some ‘superpowers’ (for example tweening them from one position to the next) but that would probably look strange most of the times too. I think that’s the reason why in a lot of games you see rather floating enemies or enemies already spawned on the platforms in these level parts.

Anyway, I hope someone can suggest a solution here and please keep us updated, if you find a way to make it work.

Here is video demo of my simple AI system:

They have Invisible Sight Sprites that trigger diferent actions under a combination of circumstances. Also have some actions restricted by randomized variables to give the ilusion of freedom (a little bit like us). I had to “Nerf” each one in a diferent way because they were equally perfect at killing each other and that was boring.

For sure, there can be conditions so if the enemy is in touch with an hidden sprite it stops moving and start a jump when it’s in collision with a moving platform so it won’t fail the movement. And for sure, I’ll try to make a system which works good and let you all updated

1 Like

Love the system you’re using, it’s very well made. In my game there will be stairs to climb and platforms, I’m trying to figure out how to use the pathfinding behavior for my platform game

1 Like

Interesting idea. The problem with using a pathfinder with a platform is the enemy would look like it’s floating or flying.

An idea that interests me would be using the pathfinder on another object and have the enemy move toward it using simulated controls of a platform behavior. If the pathfinder object got too far ahead it would have to pause or stop. (Not the player but the object following the path)

Another option is if the player ot pathfinder occasionally spawned a digital breadcrumb object to follow.

1 Like

I’ve found a big issue, I won’t be able to use the pathfinder behavior because my game keep lagging by using it so I’m trying to use my first idea. I’ll use invisible sprites to give enemy actions.

1 Like

Too bad. That was an interesting concept. I guess it would be a lot of calculations depending on how far behind the enemy was, how many pathfinder objects had to be avoided and how frequently you recalculated it. Maybe, in the future, with a less complex project. There always seems to be an infinite number of ways to solve a problem. The best way isn’t always obvious. But for me, the challenge is half the fun.

It’s not really a solution, but take a look at the 2nd scene of this example, maybe it can help:

It calculates where to jump to land on a platform.

1 Like

Now that is some clever out of the box reasoning right there.

1 Like

My “Water” is just a big fat Ladder. The “AI” is set to escape it and avoid jumping into it if the Character is not Aquatic. All the characters can “Swim”(Climb the Ladder) but some will instantly die or eventually drown (and die) in collision with it.

I got a working AI on my current game which can jump on platforms, climb ladders and collect specific items. I used Object.Distance and Object.DistanceToPosition and DistanceBetweenPositions. From the expressions reference > Expressions reference [GDevelop wiki].
And also mess around with Raycasting.

You can use all those things to calculate distance between the Enemy and the different objects. If the object is under a certain distance I use RandomInRange and a variable, which makes the AI decide whether to jump on a platform or climb a ladder.

So what happens is the AI “sees” the object, decides whether it’s close enough to make a decision, then It decides to jump or climb or continue walking. It creates the effect that the AI is making different choices to interact with the environment, although in reality it’s just random variables being triggered based on the positions of the objects to the enemy.

1 Like

So your enemies are moving in your world and they’re not following the Player, right? And Great idea!


Oh, so your not Acquatic enemies are trying to not step on Water, or are they following a default path?

When they get the instruction to jump on the water, they ignore it and ask for a new instruction.

Their Main Goal is to hit targets, if the target is at sight it will then branch, if it’s is close it will hit, if it’s far it will shot. If no target is in sight it will then branch between jumping up, or down, if down goes into water, lava, or bellow grownd it will check if the character is suitable for that action, if not, then It will ask for a new instruction.