Create a custom polygon collider based on overlapping ogjects
We all know in the game industry, everything is possible. So, I've been trying to figure out how to do something that seemed somewhat simple but it's become way more complex than I've expected.
Here's the issue. I need to be able to generate a collier on run-time. And update that collier as needed.
Take a look at this picture:
So, say the ball is moving to the right. The green has a collider. [That is simple to do.] The red also has a collider that I can turn on and off. The red piece is also moveable in any direction and can also be any shape for that particular level.
The idea is when you turn off that collider on the red box it will allow you to fall into that red area.
So I guess the question I have, is does anyone know how I can cut into my green collider using the red collider, so that I can create a new polygon collider that will let the purple ball roll over to the right and then fall into the red area. Then, be able to move that red area around and change that cutout?
I'm not asking for code here [unless you like to provide it] but any clues to how I could solve this problem would be great.
I assume, that I could, even though it seems like a difficult thing to me, cast a ray and rebuild the green collider based off of those ray results. But that seems pretty hard to me. Is there any other simpler method I could use for this?