In a game I’m working on, the player can teleport into any point of the map. This results in a case where player can be teleported for example inside a rock (or any other solid object). When that happens, I want to disable all colliders of that rock object and enable them once player exits the object. I want all solid objects to have this functionality and for them to detect the player and not other way around.
Problem I am having is detecting when player is suddenly teleported inside another solid object, since they both have a solid colliders and not triggers. I’m just trying to figure out possible ways to achieve this and would appreciate some pointers in right direction.
I’m not sure allowing solid objects to move inside of each other, THEN fixing it on reaction is the best idea.
One approach would be to, right before teleporting, take the point you’re teleporting to, and have the rock run a bounds.Contains on that point, and if it returns true, disable the object. The problem, though, is that this would have to run on every potential object every time the player teleported
Another solution would be to make the player’s collider a trigger on the frame he teleports, setting isTrigger to true. Then, check for a collision on that frame, and if there is a collision, trigger some function in the other object to turn ITS collider into a trigger. Then the player can go back to a non-trigger on that frame, and the other object can use OnTriggerExit to know when the player is no longer inside of it
I know this isn’t exactly the solution you were hoping for, but hopefully it gave you some idea of what direction to go in!