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. Dismiss Notice

Destructible Environment - Glued Fragments

Discussion in 'Works In Progress - Archive' started by Hamzah-Khan, Feb 24, 2015.

  1. Hamzah-Khan

    Hamzah-Khan

    Joined:
    Dec 31, 2012
    Posts:
    59
  2. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Liking that, can I ask how you approached making this?
    How big can the scene/object count get?
     
  3. Hamzah-Khan

    Hamzah-Khan

    Joined:
    Dec 31, 2012
    Posts:
    59
    Size of cubes is proportional to performance. The larger the cubes, the less you have to use, and therefore the better the performance. I'm not entirely sure where it's headed though, as I've not yet found an acceptable compromise between scene size and number of cubes.

    How I made this:
    1. Built a 3D object out of cubes.
    2. Assigned a script to its parent that iterates over all cubes (called fragments) and casts six rays out of each in the upwards, downwards, forwards, backwards, left, and right directions.
    3. Created FixedJoints on hit fragments to mimic "cement" between the "bricks" (cubes).
    4. Joints to Terrain are much stronger.
    5. Result is a physically stable 3d object that is always under control of the physics engine (rigidbodies never turned off) that is destructible.
    Check out v2 with:
    • Voronoi fragments
    • SFX
    • Textured inner faces



    Web player is in first post now
     
    Last edited: Feb 25, 2015
  4. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Cool, In wonder if my game(s) could have a use for something like this.. I think yes (one level in my game where I want break through stuff). The scripts involved, would you be willing to part with those , perhaps for a nominal fee? :)
     
  5. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381
    Cool!

    Performance is always an issue with destruction systems. Is this Box or Mesh based? I've used an asset for Box destruction in a project but not the Mesh destruction and it was fairly tricky to optimize. I would think that processing all of those joints at runtime is not going to scale up to a practical level very well.

    Looks nice so far, I'm always interested in these sort of assets. =)
     
  6. Hamzah-Khan

    Hamzah-Khan

    Joined:
    Dec 31, 2012
    Posts:
    59
    Cubes are using box colliders, meshes are using mesh colliders - despite them being performance intensive they are showing no signs of lag so far.

    LaneFox you are correct, the hardest part about this is scaling it up.

    khos85, I have no intention of selling any of this. I can give it to you for free, but I would first suggest that you try to make your own destruction system first. Use post #3 as a guide, if you want. This way you can make a custom-tailored destruction system all the while improving your Unity skills.
     
    theANMATOR2b likes this.
  7. Patrycki

    Patrycki

    Joined:
    Nov 12, 2015
    Posts:
    1
    Very Nice Hamzah Khan!!

    I'm trying to do something like this that you have in your second version, but I don't know how to apply the Voronoi script in the objects that I have in my scene. Can you send me your script? Because I really want to know how this things work, but I started to do games recently.
     
  8. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hi,
    Thanks for your reply, I have no idea where I'd start really, coding wise too, any tips would be cool if you can share, no worries if not :)