- Home /
How do I show an object falling inside another transparent object?
I created a transparent container and want to show the objects collected inside the container. I want to displace the collectible object from the original location but I do not want to make the object disappear. For example, a fruit falls from a tree into a glass container. Will attaching colliders to either or both objects work?
To rely on the physics engine as intended, your container must have a mesh whose shape reflects the intended shape. In 2D, a few box colliders can easily make a reasonable bucket shape that'll play nice with the 2D physics sim. In 3D, physically hollow shapes like bowls/buckets are kinda rare because they tend to be expensive/quirky, but a 3D bucket-shaped mesh is possible.
Depending on what you're going for, the physics sim can help or hinder.
Getting transparency to act right is just a matter of good shaders and appropriate depth.
Answer by VOTRUBEC · Feb 04, 2015 at 09:00 AM
First, attach a rigidbody to the "fruit", so that it falls and collides in a realistic fashion, and add a collider (I'd suggest CircleCollider2D for fruit? A Polygon Collider 2D would give you a more realistic bounce, but be careful if you have too many objects on the screen).
Next, for your "glass jar", I'd suggest using the Edge Collider 2D, and trace a general U shape from one side of the jars mouth down and around to the other side of the jars mouth.
And there you have it.
If you are moving the glass jar around to simulate catching fruit falling from a tree, use rigidBody.AddForce()
, or something similar, on the glass jar and the "fruit" inside the jar will be carried around your scene.
Your answer
![](https://koobas.hobune.stream/wayback/20220613182342im_/https://answers.unity.com/themes/thub/images/avi.jpg)