(example from Sebastion Lague video, in this example the car is cut in half as it goes through a portal)
What I want to do, is have some kind of effect to slice a collider, so that it kind of matches the rate the object is being sliced. eg. if the object is cut in half, the collider is also cut.
This seems pretty simple to do on simple objects like cubes as you can just resize the collider, but I was wondering if there was some kind of simpler way to cut a collider using a plane on more complex colliders like a sphere collider, without resorting to dynamically creating a mesh or performing expensive boolean subtractions on them.
I took a look at some other slicing methods which go through all of the vertices and creates new points, but I was hopefully looking for a method to just turn off certain vertices, instead of removing them and having to add them back slowly.
Not really. That’s why in real games you usually simply can’t go there close.
What are your options:
leave it as it is, you don’t allow things to go behind the portal (simplest trick)
turn off the mesh collider and assign a simple collider in the front if someone can go close to the visible part of the mesh
you actually slice the mesh at the portal plain, duplicate it and assign it to mesh collider (you will have perfect coverage but it is computationally expensive)
The best way to deal with this is just ignore the collider and don’t allow anything to go behind the portal.
So, I spent a few minutes thinking about possible solutions, and I came across this video
In the video, he uses an OnTrigger effect to Disable the collision between the object and the target mesh, allowing it to go through. Suffice to say in the video they still have a second collision mesh created to have the object hit the hole (which is expensive), but for my purposes I can just create a giant block to disable the collision on one side of the portal instead, and it should be good enough for my purposes.
Incase anyone was wondering what I was really hoping to make, I was trying to materialize a bridge using a shader, and have it so while it was materializing, the collider wasn’t entirely there.