Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Solved] Question - Destroy object with gravity

Discussion in 'Scripting' started by kholyphoenix1, Nov 18, 2015.

  1. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    Hello,

    How do I gravity destroy an object into several fragments and then do the fragments disappear?
    I tried using more RigidBody believe this case is really just script.
    PS.: C#

    Thanks a lot!
     
  2. IroncladEarl

    IroncladEarl

    Joined:
    Jul 3, 2013
    Posts:
    87
    Are you trying to destroy the object if the impact is too strong? Sorry, not understanding.
     
    kholyphoenix1 likes this.
  3. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    I want the object to be destroyed in several fragments. When gravity is disabled on the object. Or something.
     
  4. IroncladEarl

    IroncladEarl

    Joined:
    Jul 3, 2013
    Posts:
    87
    So you could probably create the fragments (with rigidbody disabled) and put them together as children of a parent object. When gravity stops working (or whatever your trigger is), you can then enable their rigidbodies and then create a Rigidbody.AddExplosionForce in the center. This should trigger a countdown on the parent and then the parent is destroyed.
     
  5. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    Ah thanks!!