Enemy Collision Problem

I want to make the enemies don’t stack with each other. I have an enemy that will chase the player but the problem is that if there are multiple enemies of that kind, at some point it will stack with each other and it will appears that it’s only one enemy for the others are beneath that enemy. I try to use the “bounce” behavior to make them separated but sometimes the force increases and decreases too high and the directions becomes unpredictable. It seems like the “bounce” behavior only makes the object give force but in the opposite direction and when multiple bounces occurs in one time it glitches. Is there another way to make enemies don’t stack with each other? So they will act as a solid object. Hope someone helps me out with this.

Is this using pathfinding or another movement behavior?

1 Like

I use bounce behavior but It sometimes glitches for it cannot handle a lot of forces happening to the object and also when many objects collides in one time. I want to make the all object as a “solid object” to make them unstackable. Almost all games have a solid object behavior that makes all objects can’t go through each other.

@Silver-Streak is asking, while it is chasing Player, which behavior is it using?

1 Like

How are you moving the objects? By applying a force, moving them or some other method? Each way has a different way of handling the collision.

Bounce isn’t a movement behaviour on it’s own. You must be propelling the objects by some other means.


Oh. I’m sorry. The enemies chases the player and it does not have trigger once so the enemy will chase the player continously. At some point they will get stacked up for they are in the same speed and same target location. My goal is to make those enemies a “solid object” like most of the games rn. That even if It’s a platformer, top-down, or any genre, the objects will never stacked up with each other. Just like in Unity where if you labeled it as a solid object, it really act as a solid object. I don’t know if Gdevelop have this kind of behavior but I hope y’all can help me with this😊

But which behavior will it use to chase down Player?

1 Like

Maybe is too simple solution, but what about use “SEPARATE OBJECT” ?

i’m using this way: think about 10 objects, the first isn’t affect by “SEPARATE OBJECT”, the second object move away only from the first object, the third move away only from the first and the second object and so on, a waterflow system.

briefly, in the object variable of your enemy, make one like “ID” and instance it (get it? must be istanced) from 1 to what you want. If the ID of the collided object is lower than the ID of the object you are currently checking, thne perform “SEPARATE OBJECT”.

better perform under a “repeat for each istance of ENEMY”

p.s. enemy is randomly spawned so you have difficulty to instance a different variable value to it? this is another “How do I…”

1 Like

I also thought so before but unfortunately, it doesn’t work. It glitches the object, teleporting like glitch.

1 Like

AH. Well, maybe watching the events list can be useful. For now, that solution is the only i have.

1 Like

Yup! That’s also the problem with “bounce behavior” it does make them unstackable but at some point it glitches. For it cannot do a lot of interaction ones and the force of the objects act wild😂 My events for the object is to give instant force to the enemy and chase the player. It isn’t have the trigger once so that it will continue chasing the player.

Ah, finally we have the answer.

I’m assuming your enemy objects have a hitbox object attached (not to be confused with the sprite’s collision mask). If you don’t, it’d be a good idea to do so. I would think checking the enemy isn’t in collision with another hitbox, and only then apply the instant force, could be the solution.

1 Like

does path finding behavior fix all this?

so enemies will avoid collision with others

1 Like

No it will not fix this behavior

1 Like

This is the event I’m currently using.

And this is the behavior I’m currently using.

It works fine but it sometimes glitching when there’s a lot of collision/bounce trigger happens at the same time. The enemy will continue to move to the player no matter what so even if it bounce off, it will continue that’s why when there are a lot of them colliding, some may teleport or have a huge boost to their force and others change it’s direction in short, they were glitching.

I used the bounce behavior for some games but the thing is this behavior uses permanent force to move the object and in some conditions an object with a permanent force never stops.
So is better to create your own behavior or just use instant force or maybe a custom movement it depends on your game.


The way I’ve always handled this is to use pathfinding.

From what I understand, bounce is not meant to interact with a large number of itself, which is likely why you’re experiencing what you are.

If you use the pathfinding behavior for movement instead of instant forces, you can do this:

If your enemy is in collision with another instance, pick the instance that is furthest away from your player. Then change it’s speed to 0. As soon as they’re no longer in collision, its speed will start back to normal.


I’m really sorry for I don’t know how to use pathfinding. I try what you’ve said.

I try to replicate what you’ve did but it’s not working. I just added that and didn’t change anything to the events I’ve shown you before.

This one.
I guess I will do something about the pathfinding itself but I don’t know how. Hope you can help me how to really use pathfinding because I don’t really have an idea about it.

Wait! Maybe I will create an example about what @Silver-Streak told and give you. You will see how things work. Just wait for it until I create an example for you.

1 Like

Hey! Got it working. Preview is here. And events are these:

But, they do stack up when you stop and they collide with you. Working on that too.

Edit: Couldn’t find solution. Maybe, you can delete Enemy whenever it is in collision with Player, this will create an illusion like thing from where we can’t see the stack up.

1 Like