Search code examples
unity-game-enginecollision-detectionaugmented-realityvuforia

3D object falling through ARGroundPlane


I`m using Vuforia plugin Unity, I added 3D Water can to my scene, and make it child to the Ground Plane Stage, when I run the game the object occurs, I add Box Colliders to both Ground Plane Stage and the Water can, also I add rigidbody to the can , when running the game the can fall through ground (doesn't stop falling ) How Can I fix this and make water can stop falling ? I use Vuforia 7.5.26


Solution

  • Okay the problem is your object starts falling when you press play regardless of whether you found a plane or not to solve this problem add rigidbody to both ground plane and your water can. Uncheck use gravity in both of them. Then add these lines to your OnTrackingFound function in DefaultTrackableEventHandler

     var rigidBody = GetComponentsInChildren<Rigidbody>(true);
    
     foreach (var component in rigidBody)
            {
                if (component.name == "Cube")
                    component.useGravity = true;
            }
    

    This will cause gravity to apply to your water can when you click on the screen. You can modify it to usecase for lifting and dropping. But the main problem is applying gravity before detecting ground. Good luck!