Enemy Collision Problem

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.

2 Likes

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.

2 Likes

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

You have to set the enemy on a path. It doesn’t just happen automatically. You need to tell the pathfinding object where it has to go to.

So instead of moving the enemy skeleton to the wizard player using force, you use the pathfinding action move to :

And are you sure you want to invert the distance condition? It’ll only move skeleton enemies that are over 200 pixels away.

1 Like

The problem with this is that the enemy will target the player all the time, not just when they’re more than 200 pixels away.

1 Like

Yes, but this is just a demo of fixing the enemy collision problem, not making the enemy and setting everything.

1 Like

I added that condition because I want the enemy to attack. (shoots bones) It’s another topic but it’s working fine.

If I use Group instead of just that type of enemy, would it work?
Edit: Because my game have a lot of different types of enemy so I need all types of enemies to not collide with each other.

I don’t know about that. Try experementing with it.

1 Like

So long as they all have the pathfinding behavior, a group will work just fine.

1 Like

So I’ve tried all your suggestions and it kinda works but the condition pick the nearest enemy within the player is kinda bad for the enemies looks like this when played.
image
I know that this condition is the main reason why this is possible. For it stops the nearest enemy so that others can move to separate them to each other but the problem is that when the nearest enemy stops, others will go above it and it kinda looks ugly because their z-orders are different some goes above and some goes beneath.
I expected it more like this:
image
Where they didn’t stack at all (depends on the hitbox the enemy have) like in physics games where the blocks never pass through each other but always finds a way to move in a certain position.

I will think about it, about how to do that and if I got the solution to your problem, I will share it with you here.

1 Like

Thank you so much! I’m sorry that this problem takes too long to solve. I really appreciate y’all for helping me with this!:heart:

Edit: Hoping to solve this soon!:heart:

1 Like

Don’t worry everyone wants this solution for their games HAHA

i tried setting the object as impassable but that disables movement perhaps we just need it not to and using costs don’t really work

seems the longer i try search the forum for a solution the more post of people who have encountered the same problem with no good solutions, now i know why gdevelop games are like 90% platformers with linear ai’s

this post might give you some ideas

im going to go look if some extensions may help or maybe some genius will make one :DDD

1 Like

nice graphics anyway. I think you can’t rely on a single behavior, but you have to write your mixed routines of various gifts that GDEVELOP gave us.

2 Likes

You are right @ErmesBertone

2 Likes