Make projectile collisions with walls be one way#379
Conversation
This lets us tell apart which terrain is floor and which terrain is elevated Related to #277
… escaped that terrain Collisions with walls are now handled by raycast instead of by the rigidbody itself. On spawn, the projectile detects which tiles of each tileset is 'touching', and if any of those tiles is an elevated terrain, it adds that tilemap layer to a collision exception list. As soon as the projectile isn't touching any tile from a tilemap in the collision exception list, that exception gets removed. Had tocheck positions instead of using the raycast itself on spawn because not all tiles with elevated terrain have collisions: for example, the projectile could have spawned in the middle of a wide mountain and it'd be in elevated terrain but it wouldn't find any collisions until it got to the edge of the cliffs. Also, used several points to find tiles in its bounding box because if I only checked the origin position of the projectile, it could spawn just at the side of a cliff, not add it to the exception list, and then be impulsed into it, causing the projectile to get stuck in the cliff. With this implementation, it is a bit more generous with what tilemap layers will end up in the collision exception list. Related to #277
|
@JuanFdS thank you so much for attempting so many ways to fix this! I placed an enemy behind a wall but is not doing what I would expect: Grabacion.de.pantalla.desde.2025-04-29.16-48-58.webmI don't think there is a general way to fix this issue without adding a new "height" or "z" or "elevation" property to world objects. I have an idea for how to do it but it would be a major change. At this point I would rather change the level design than trying to fix this in a complex way. What do you think? |
Ohh, I see, I kind of expected it to work the way it did because the ink blob spawns on the mountain I think that for the mvp it's okay to avoid this issue via level design and tackle these edge cases later! |
Yes but even with that, if the enemy is set to move around (something not part of current rounds) the illusion will be broken. Here is more or less what I would do:
So in this sketch there is a 6x6 tile:
And this is just the beginning. There should be ways to move (or teleport?) things from floor to floor. For instance, with a new "cliff" collision layer, the projectile can fall from Floor1 to Floor0 on contact.
Yes indeed, I would avoid this issue for the MVP. |
Yeah, I think the scene tree approach might make it easier to understand when level designing 🤔 (the alternative could be an altitude property but I think it's fine to group by the altitude they are in). Closing this to tackle it after MVP. |


The collision with walls is turned back on once they left that elevated terrain.
This is an attempt to fix the issue mentioned here:
#358 (review)
How this works
Instead of handling collisions through the rigidbody, handle those collisions through raycast. That way, we can decide what to do when we detect that the raycast is colliding. This lets us set collision exceptions with some nodes (like the tilemap layers) if needed.
When a projectile spawns, it detects if any point in the vertices of its bounding box is in an elevated terrain tile and adds it to the exceptions list.
Then, every frame it checks if the projectile's bounding box has escaped that tilemap layer (no vertices are in any tile of the layer), and if that's the case, it erases the layer from the exceptions list.
Other possible solutions (❌ were explored but couldn't make them work)
RigidBody.add_collision_exception_with: that would be great for this use case but sadly it can't be used with objects that are not CollisionObject2D, and tilemap layers aren't: Collision exceptions don't work with TileMap node godotengine/godot#17090