tileSetLayers and physics Layers (in relation to spikes)

Godot Version

4.3

Question

How can I use physics layers to make spikes in a platformer game?

I have 2 physics layers
Layer 1 is for normal stuff to colide with
Layer 2 is for deadly stuff that kills you
Screenshot 2024-10-01 at 6.08.51 PM

Now I want to be able to call the function death() when the player (on collision layer 1) colides with the spike (on collision layer 3)

how would this be possible?

Umh.You need to set the Collision Mask of the player to match the Collision Layer of the collider that hurts it.

Collision Layer - collision where the object is.
Collision Mask - collision the object scans.

Personally, I can’t seem to get the collision layers and masks to work properly anyway. If you’re checking A against B, Godot seems to assume the opposite must be true as well. Which it isn’t.

If the spikes are never from the same tilemap- if if you’re using other nodes for the spikes - you can make a ‘group’ (let’s call it ‘spikes’) and check against that.

  • groups are made in the inspector, same screen as adding signals.
  • Godot has functions called something like ‘is_in_group(“group name here”)-