Search Unity

problem with breakable moving object

Discussion in 'Physics' started by freddannn, Jan 5, 2016.

  1. freddannn

    freddannn

    Joined:
    Jan 2, 2016
    Posts:
    6
    Hiho,

    I have a problem with a sphere that can move and break. Basically, I want a player controlled sphere that breaks on collision (pieces fall off) thus affecting movement.

    What I have now is a base sphere mesh with a rigid body that does the movement, then all the pieces of the sphere are kinetic children that become active on collision. It half-works... The pieces fall off at a decent rate when colliding, but the movement of the sphere does of course not depend on them. I've tried messing around with the different options (kinetic, gravity etc) but the result is usually an explosion or the sphere falling through the ground... Any ideas of a good way to achieve this? Is it a Unity issue or should the sphere model be edited somehow? I'm kinda new to Unity.

    Anyway, the base sphere is currently moved with Rigidbody.addForce, and the children are detached like below OnEnterCollision
    Code (CSharp):
    1. rb.isKinematic = false;
    2. rb.AddForce (collision.impulse);
    3. rb.transform.parent = alternativeParent; // for tracking
    4. Destroy (rb.GetComponent ("playerPartCollider")); // destroy this script
    Thanks