Pass through StaticBody2D? Easy or Not?

Godot Version

4.2.2

Question

Hi all,

I have a bomb in my 2D game that you can pick move around, put down and if in the right spot(s) will blow up certain “breakable” items, all that’s working.

Just now I set a staticbox2d collision in the middle of the bomb so my character couldn’t just walk through the item, to give it some importance, but, I still want the monsters (enemy) to be able to go through it. Now, is this possible to do it easily? I don’t want to have to go through layers/masks or any of that because I don’t really understand that. If it not easy I can live with it as is.

As always any help is greatly appreciated.

Regards.

You will have to set separate collision layers/masks. Put your Floor/World, Player, Bomb, and Enemies on different layers; 1, 2, 3, and 4. It would be best to set layer names for them in the project settings.

Have your player mask the Floor/World, Bomb, and Enemies; 1, 3, and 4

The Enemies will mask only Floor/World, maybe players too; 1 and 2

Static bodies usually do not need to mask anything to function.

I forgot to mention that the enemy is using a raycast to turn around from the group name of “xplosive” can this be circumvented in any way?

What needs circumventing? That sounds fine.

The enemy has a raycast and when it hit the explosive/bomb it turns it around to go the other way whereas I want it to go through it. I only want the explosive to stop the player

Oh so I think you want the raycast to also follow the enemies mask, 1 and 2; walls and player.

I am still having troubles with the collisions/masks, but, by following what you said and NAMING the layers it did help.

And most importantly got it working!!!

Thankyou for that :sunglasses:.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.