Search Unity

Realistic dynamic destructible object?

Discussion in 'Physics' started by squigglyo, Jan 18, 2018.

  1. squigglyo

    squigglyo

    Joined:
    May 21, 2012
    Posts:
    107
    Hey guys

    Ive had a look around and cant really find any examples of what I want to do that have any information I can use.


    I am in the process of building a game and one of the requirements is a realistic tree. This tree needs to be able to be realistically chopped down. So a chainsaw/axe is controlled by the player allowing them to make calculated cuts. These cut offs would then fall away realistically.
    At any time, the tree may reach a point of no return based on weight distribution and start falling, splintering, cracking, etc.

    Everything ive seen so far either seems scripted or doesnt look realistic.

    Some of this realism might be too much but my main question is
    - Is it possible to cut into a mesh and then if enough cuts are made then a piece dynamically fractures off. (If you cut a tree with a chainsaw, if its the trunk, you would have to cut multiple times before a piece would fall off)
    - Can these fractures then act independently and realistically in regards to physics/falling
    - Can the core mesh (the tree), after each cut, re-calculate its weight distribution and if necessary react under its own weight (by falling, or swaying, etc).

    I've found asset packs like this one
    https://www.assetstore.unity3d.com/en/#!/content/9411
    and this looks awesome, but it seems like its more for show rather than realism.

    Closest thing ive found so far is this game

    This seems very scripted though, but overall looks kind like what im after.


    Im figuring that if this is not possible in the ways im looking for, then scriptable destruction is the way to go and it just needs to 'seem' dynamic, so enough scripted destruction to mimic it. So start with a tree, have maybe 20 places it can be cut, play through the relevant fractures/animations/etc, then there are 20 new places to cut, etc.
    I have a small budget for this game, so if it actually is possible, my next step would be to possibly look into hiring someone to help develop this aspect of the game.
     
  2. maximilianramann

    maximilianramann

    Joined:
    Nov 27, 2018
    Posts:
    1
    Hello, I am currently looking into solving a very similar problem, have you had any luck with this?
     
  3. Ox6c23

    Ox6c23

    Joined:
    Aug 30, 2018
    Posts:
    5
    I‘m currently looking into the same thing and haven’t been able to come across a solution besides pre-fracturing the mesh and replacing it, which is not dynamic at all.

    I also tried to subdivide the mesh at the point of collision and simply ‚indent‘ it - without success unfortunately.

    It would be beyond awesome if someone has some input on this.
     
  4. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    That's not dynamic at all. You can see the lines where the game is telling you to cut as the model has already been pre-cut there. To dynamically alter the meshes your going to have to iterate through the vertices, its very complicated and something programmers who build engines know about. To do the above is possible in a number of ways, the easiest being pre-cut the model when making it.
     
  5. FastKillteam1

    FastKillteam1

    Joined:
    Sep 20, 2017
    Posts:
    50
    The way its done in "some other engine" is to have a few "caps" modeled in say three or four sizes, for the various tree trunk diams. Then a "boolean cutter" mesh, these are defined in the code and added to a material effect trigger similar to how we read any hit texture in unity. the material on the tree trunk is flagged as breakable. Hit point causes the boolean operation at that exact point, or very close to it, then the exposed hole is capped with the predefined cap. But, that's not all. Trees must be modeled with volumes for touch collisions, and air resistance/AI blocking (these are all defined by material tags also), along with the setup of branches etc in a modelling tool. What has surprised me during extensive testing is the speed this can be achieved. Not much cpu hit at all really. But LOTS of setup and tweaking (max users make use of custom obj props when modelling usually). I am working on a solution for Unity that should turn out much much simpler to use than that and aim to have the needed values after the hit fact calculated at runtime. The branches and weight painting will need to be handled by hand to achieve the best results though. If you have used "some other engine" you will know what I am talking bout here if you ever tried to make your own breakable trees.