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

Multiple objects breaking

Discussion in 'Scripting' started by Stixxeh, Nov 12, 2014.

  1. Stixxeh

    Stixxeh

    Joined:
    Jun 6, 2014
    Posts:
    4
    Hi all, sorry if this isn't the right area of the forums, couldn't find a simple Q&A section!

    In short I'm planning a mobile game that would heavily focus on multiple physics-based objects being able to be broken by the player and react with the environment- think the classic smashing barrels/boxes into fragments thing here. As a Unity rookie, my question is essentially.. is it possible? I'm just starting to learn Unity but I'm already worried drawcalls and such could be an issue (if I'm making the objects pre-fragmented etc) Any tips for how I could make something like this and what methods would be best?

    Cheers all.
     
  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Make 2 prefabs - a normal one and a broken one. Swap the normal out for the broken one when the player hits it and apply whatever physics you want to the broken one.
     
  3. Stixxeh

    Stixxeh

    Joined:
    Jun 6, 2014
    Posts:
    4
    Cheers for the reply. To clarify I'm not so much asking literally how to break an object- I'm asking if a game focusing on physics-based breaking would be possible? As I said before I'm worried about the potential high amount of drawcalls. A lot of objects would be modular so I'm assuming I can atlas the textures to lower the costs- although I'm not 100% sure if you can atlas objects if you want them to act individually?
     
  4. slay_mithos

    slay_mithos

    Joined:
    Nov 5, 2014
    Posts:
    130
    Well, technically, it should be withing the realm of possible.

    As for what you could have to do, I'd say to simulate the damaging force as a sphere, and apply the forces and destruction to the objects intersecting with that sphere, potentially with a distance modifier.

    Now, it's far from perfect, because it would also harm items hidden behind others, and such, but I think it's a decent place for a start.

    After all, that's also how explosion damages are done, those that take cover into account are mostly built uppon that sphere being shaped by the objects and their resistance values.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,523
    You only need to use physics objects if you want the fragments to react in a physical simulation. If you don't need this, what about using a simple animation?