Is there a way to enable and disable collision of each individual pixel in a tile? (or any alternatives?)

Godot Version

Godot 4.6.1

Question

Hi! I’m trying to remake a gamejam game called Prizm (https://fury1012.itch.io/prizm) that some friends and I worked on (i did the art!!!), which was originally programmed in GMS2. The main gimmick is that you have a light that comes from a cool little prism thing that shows color and hidden objects!! (here’s some of the original gameplay)

ezgif-14887af6b5740373

ezgif-14d197a6128b7e10

Above is what I currently have

As shown above, I mostly figured out how to do the masking visually, but I’m having trouble finding a way to mask(?) the collision as well. The only thing I felt mostly confident in trying so far is making each pixel in the tileset its own tile and having an Area2D within the light to enable and disabled each pixel-sized tile’s collision.

But, I didn’t get very far since I’m not sure find a way to prevent the pixels from being stuck in the middle of the tile grid.

So if there’s any other possible solutions I could try or a way to make mine work, please let me know!!! Thank you!!!

I am not good in 2D but your Idea is creative. i don’t think There are no Toggle or any option for tilemap may be should use this approch.

  1. Assign layer for that tile map Then whole Tilemap layer will be enable/disable Collision
  2. or you need to file that tile and manually remvoe it from ceil number ( may be worse approch for you)
  3. you can use sprite for that specific area is wil be easy to adjust and change

right now i only this getting in my mind/

1 Like

You can’t really do per-pixel collisions as Godot’s physics is polygon based. So you’ll need to re-calculate the collision polygons:

Whenever the light triangle or a relevant collider moves:

  • enable all colliders that are fully inside the triangle
  • disable all colliders that are fully outside
  • for all colliders that cross the edge, re-calculate the colliders by calculating the intersection polygon between the original collider polygon and the light triangle
3 Likes

Earlier I found a solution by using body_shape_entered and exited signals instead of body_entered and exited for body_rids. I also set a tilesetlayer to 4x4 tiles with 2 tiles with different physics layers, one that collides with the player and one that doesn’t.

So by using var tile_pos = body.get_coords_for_body_rid(body_rid) for tile coordinates and using that to get the cell data with tile_data = body.get_cell_tile_data(tile_pos) all inside of the entered and exited signals, I set the tiles that enter the light triangle to the player-colliding tile while whichever tiles exit the light triangle are set to the non-player-colliding tile.
I’ll be back if I have any other issues though, thank you!

3 Likes