Change collision layer in Physics engine 2.0

I am making a fishing game where the player will release the bait at a certain point. When the bait is going down to the bottom of the sea I don’t want it to collide with fish, but on it’s way up I want to be able to catch fish. Can I activate or deactivate physics collision during gameplay? I can’t find any actions to change the Physics engine layers.



If one object’s layer matches another object’s mask, collision checks are made.

Thanks for answering @MrMen!
I have tried that option but it doesn’t seem to work. Actually nothing makes sense because even the revolute joint messes things up when I catch the fish. The fish starts rotating and going all over the place, no matter what I do. I have tried angular damping, restricting angles, changing density etc. These are my current settings:



Now I tried to also enable the mask and then the layer is activated, so what’s the difference between mask and layer?
Also, why is the caught fish acting so strange when caught? Besides being pissed :slight_smile:
It’s as if it struggles to turn it’s tail upwards, whatever I do. And sometimes it rotates, goes sideways etc. I have tried to change the Y-velocity when the fish is caught but it makes no difference.

When you activate/deactivate a layer, you should also activate/deactivate the matching mask.

Also, activating a layer & mask does not deactivate the other layers and masks.

Are you connecting the joint at the fish centre? If so, that’s pretty much the centre of mass, and will cause the object to spin and jiggle around. Create a point that’s near the edge of the fish object, and connect it there.

Layer is what the object uses to detect another object for collision with the matching mask.

See the wiki for further info

Actually I have two points for the fish, mouth and tail, so I am not using the center point. The “Mouth” point is connected to the “Hook_point” of the bait (I have tried both revolute and wheel point with the same result).

Make sure the bait’s Hook_point isn’t then connected to the line.

Have a look at my rope physics demo/example that comes with GDevelop. it uses a series of objects linked top and bottom to create a chain/rope :

There is no line. I am just using the pulley joint connected with the baits first point (Attach_point) to make the bait go back, to the fishing rod. I’ll have a look at your example. Thanks for the advice.


Now I’ve had a look at your demo/example but I can’t see anything there that makes my project seem clearer. Maybe the problem is that I have set the Y velocity of the fish to -1 while the bait is sinking, but I seem to need that since the fish keeps going down regardless of it’s density and gravity. If I set both to 0 (zero) the fish still keeps sinking deeper into the sea…

Ok, so now I have more or less stopped the fish from rotating and being all over the place. The reason it was rotating and moving in a strange way was because I had given it a “Polygon Shape” around its mouth, for a natural collision (fish biting the bait with the mouth). BUT if I choose the “Box” shape, the collision will be on the entire fish and not just on its head. I guess I have to create another small (and hidden) object attached to the head to get a smaller collision mask…