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)
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.
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
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!