Why Collisions Do Not Occur


I want when my main char (circle) to collide with any instant of coin1, and the speed of any coin1 that has collided becomes faster. Here comes my code:

But when the collision occurs, nothing happens. Why?
I should state the coin1 object has the tween behavior.

When you add an “instant force” to the coin, the event has to be constantly ongoing.
In your sheet, when circle collides with coin1, instant force angle is applied. But when the circle goes away from coin1 and the collision is not happening anymore, the instant force gets removed as well.
I might suggest you look into either adding a permanent force, or adding to a number variable for every collision which will be used for coin1 speed.

Also I might point out, your collision with monster1, I believe you might want to create the trail2 first before you delete the monster1. Otherwise Trail2 will probably not be created since there is no monster1 position for it. I might be wrong though. If so, then please ignore this.

Your issue is that you are using physics2 collision conditions (they have the atomic icons), and then adding non-physics2 forces (they have the hand with finger icon).

Additionally, if coin doesn’t have physics2 as a behaviour, the collision will never be detected. Physics collision detection is only between 2 physics bodies. If you do add physics2 behaviour to coin1, take note that you will get unexpected side effects.

However, I’d suggest you use the non-physics2 collision detection and remove the physics behaviour from the circle object.

Yes, and this is my trouble.
Are there any methods available for collision detection other than the collision action?
I mean a collision between a physical and non-physical object.

The only way you could check for collision between a physics object and non-physics object is to check for a collision between the GDevelop collision masks of both objects.

But you cannot check for a collision between a GDevelop collision mask and a physics collision mask. The physics and GDevelop collision masks are different things. The standard collision will be a mathematical check whether the sprite collision masks overlap. The physics behaviour uses Box2D as it’s physics engine, uses it’s own proprietary collision mask and it doesn’t know or understand the GDevelop collision masks.

Both of my objects have their own predefined collision masks
However, I’m still unable to use the collision. Should I find the action collision mask?

If by this you mean standard GDevelop sprite collision masks, then of course you cannot use them in for physics collisions.

Collisions are either between GDevelop collision masks, or between physics collision masks. You cannot mix the two.

You can check the distance between two objects and consider it a collision if the distance is small enough. But otherwise, there’s not many other options.

If, for some reason, you feel your game needs this physics & standard GDevelop collision interactions, then I think you should redesign your game.

1 Like

Do you mean I should create a separate collision mask for each object if I want to use physics collision?

But there is a "Ray Cast " action.
Could this action be beneficial for me?

Let me add my 2 cents from what I’ve learned from testing. It’s important to understand the process. It’s also important to realize that because something works now in a certain way doesn’t mean it has always or will always work. It’s best to use things as intended otherwise your result might be inconsistent.

I agree. If objects are being tested for collisions then they should all either have have the physics behavior or not. And if they have the physics behavior then the physic’s behavior collision condition should be used.

Now, to the explanation.

There are 2 masks. The basic and the simplified physics mask. They both continue to be checked. If the masks aren’t identical then the 2 collision conditions will trigger at different locations. A square basic mask will trigger as a square regardless of the image being a ball.

If the basic collision mask is smaller than the physics mask and both objects have the physics conditions then the default mask condition will not be triggered because the behavior prevents the objects from getting close enough to each other so the basic masks overlap.

A similar situation happens with the platform behaviors.

Edit: in the original post, it looks like the one object didn’t have the physics condition but the physics collision condition was used. The physics condition won’t work if all objects don’t have the physics behavior because it’s trying to use the physics mask not the basic.

1 Like

A separate physics collision mask for each object.

Not really. It’s a processor expensive way to test for collision and you’d have to have a very short raycast so that you don’t detect further away objects.

So I should create the physics collision mask in the object property.
Do I understand correctly?

I think you have the right idea - the physics collision masks are defined in the physics behaviour on the object:

1 - Choose the shape of that is most suitable for the object.
2 - Use the object image to help align the collision mask.

Based on your statements, the only remaining option for me in this case is to use the “distanceTo” action…

Am I right?

“Does the number provided represent the absolute value of the distance?”

"DistanceTo " is a good option. It is a circular collision, and since you are looking at 2 round objects (a circle and a coin), it’ll do the job just fine.

Do you mean the result from the DistanceTo function? It should be the distance between the origins of the 2 objects.


For example:

a = ±3
result = |a|

Yes, it is absolute. Distance does not have a direction associated with it, so a negative distance would make no sense.

1 Like

Thank you very much. It works perfectly fine for me.