- Home /
How to keep a GameObject inside a collider?
Say I want to make a sphere stay inside a box's boundaries. I tried to create a box collider for a GameObject and put a sphere inside, but that didn't work. The sphere fell through. Is it possible to create a boundary for a character and how?
Answer by tadadosi · May 18, 2020 at 12:22 AM
You could create the boundaries with 6 box colliders like in the image, that way a sphere with a rigidbody will stay inside and react depending on the parameters you set.
This solution will not work if you have a complex shape for your boundaries.
Answer by KapoorArjun19 · May 17, 2020 at 05:17 AM
You can try to create colliders around the area you want to move your sphere within! You can do this without any code, you just need to setup static colliders to collide with objects on certain layer and put the sphere you wanna move on that layer. This will help: http://docs.unity3d.com/Manual/LayerBasedCollision.html
Answer by wewewu · May 17, 2020 at 05:20 AM
Things are only able to collide with the "out side" of a collider (which you can't look through, whereas you can look through the inner side). Try to make it with several colliders or do it with script.
Your answer
Follow this Question
Related Questions
Horizontal gravity on One gameobject 2 Answers
Script for alternative gravity? 2 Answers
How To Set Individual Rigidbody Gravity [Solved] 3 Answers
How to make a game object from several game objects in Unity? 0 Answers
rigidbody.velocity not working on x axis 2 Answers