Unity gaming question- why won\'t the cube collide and fall into the floor of th
ID: 3876922 • Letter: U
Question
Unity gaming question- why won't the cube collide and fall into the floor of the box?
Unity 2017.3.0f3 Personal (64bit) Lab 1.0.unity - Lab 1.0 PC, Mac & Linux Standalone (Personal) Center Local Layers Layout Scene Ga Asset S Services E Hierarchy Create Inspector Shaded Gizmos -Cube (Mesh Filter) Lab 1.0' Main Camera Directional Light Mesh Cube Box Collider box Edit Collider floor side1 side2 side3 side4 Is Trigger Material Center None (Physic Mater do x 0 Cube Size Mesh Renderer Lighting Materials Dynamic Occluded A Rigidbody Mass Drag Angular Drag Use Gravity ls Kinematic Interpolate Collision Detection Discrete constraints 0.05 Project 4 | | * Favorites Assets All Materials All Models All Prefabs 1 1 Mesh Collider Assets Convex Lab 1.0 Is Trigger Cooking Options Material Mesh Mixed None (Physic Mater Cube Default-Material Shader StandardExplanation / Answer
For calling a collision function in unity there must be a rigidbody physics component attached to it and enabled. Check the inspector there is a rigidbody component in it. The inspector is the properties box on the right side of the UI. Enable the rigidbody component for both the ball and the mesh acting as the floor.
Now you just need to create a box collider around both the floor and the cube. This would allow the meshes to perform actual collisions and calculate the physics based on the gravity of the object.
When two meshes collide it will call the function OnCollisionEnter and perform an action that you have set in the script file. Collision meshes have a collision script attached to it already you just have to create what will happen in the function after the two objects collide.
Hope this helps…
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.