Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Destroyable Buildings v4

Discussion in 'Assets and Asset Store' started by KlaRo115, Feb 9, 2013.

  1. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi folks, prepare yourselves for the new ...

    Destroyable buildings v4.1 !!!
    edit: download links updated, but compatibility with unity 5+ not verified!

    This is basically a complete solution for creating large destroyable structures and architecture for any kind of game. The whole thing is very modular and rather easy to use, but excessive use may kill your performance, so use at your own risk ;)

    This version has some all new features, much better and easier setup, examples for all situations I could think of, as well as a collection of easily reusable scripts and assets.

    Features:
    - Setup helper
    This script allow you to generate links between different stricture elements within minutes. Simply attach to your construction parent object, right click the script and hit "Setup structure links" and you're done.
    - Destroyers
    These scripts are all driven and triggered by "DestroyMaster.js", a simple script that allows for simply breaking parts (replacing them by debris) or assembling several parts into "chunks", larger elements of a structure that stick together as a whole dynamic piece, giving much more realism and spectacularity to your scene.
    Different destroyers cause different types of destruction. "DestroyBrickWall.js" gives you other results and options than the default destruction, it spawns bricks or debris in either regular or irregular patterns within a given volume. The amount of debris spawned can be modified, you can even define wether every second row of bricks is dispalced, gving it more stability, etc...
    - Triggers
    These scripts are attached to structure parts (objects with DestroyMaster attached) or objects with a collider attached. They react to the respective inputs provocing the collapse of their corresponding structure part, be it collisions, fire or damage.

    - Example scenes
    There are five example scenes: brick and concrete walls, a space ship hit be asteroids, a wooden tower and a small house using both wooden elements and stone walls.

    - Individual debris handling
    For performance issues, you'll often need to eliminate most of the debris produced during a destruction. But how can you do that the nice way without horrifying the player? Simply smoothly faing bricks out or making them static after a while, all scripts included.


    Known bugs: (v4.1)
    - Odd chunks
    Sometimes your chunks will look very unstable, but most sources of this bug were removed. (Rare)


    I hope you'll like it, allthough I would appreciate some feedback. Feel free to adapt the scripts to your own needs, etc... (mentioning me in the credits of your game would be nice too) ;)


    Download:

    Entire package: Download now (v5f latest version)

    edit Feb2017: new download links for v5, fixed typos.
    edit Jun2018: new download links for v5 (again), removed deprecated v4 links.
     
    Last edited: Jun 19, 2018
    Enrico Monese likes this.
  2. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    About chunks:

    Chunks can be created as you like 'em, but for more realism, make sure chunk generation matches the material your structures are made of. A light wooden structure will produce more far more chunks (large segements breaking off the structure) than one made from brick. Concrete also gives larger bricks, in that case increase "addToChunkProba" while keeping a moderate "createChunkProba". Steel and other more flexible materials will produce chunks in most situations, it won't look realistic if a steel bridge is decomposed into screws and tiny metal bars, so you might want to increase both "createChunkProba" and "addToChunkProba".
    And last but not least: Use different materials for one construction: A wooden bridge with a metal frame and a brick basement will look awesome on destruction :p


    Have a look at this collapsing wooden tower:
     

    Attached Files:

    Last edited: Feb 11, 2013
  3. mr_Necturus

    mr_Necturus

    Joined:
    May 17, 2010
    Posts:
    2,956
    You can upload it to another site and link to you post via menu placed just above text filed.
     
  4. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    I managed to upload a series of low-res pictures of the collpasing tower.

    I'm still working on this project, and I just found the source of some bugs,

    Bugfixes:

    - Way smaller gaps between chunk elements.
    Gaps between chunk parts are now far less frequent. If they however still appear, then they'll be smaller than before. To enable this "bug avoidance", just enable "chunkDistCheck" in the inspector.
    - Less floating objects.
    There have been cases in which some construction parts somehow didn't break along with their supporting parts. I managed to reduce this as well, by adding a new option for using part's individual angles for creating links between them and other parts (called next parts).

    If you're still experiencing some of these bugs, try playing around with link and base angles. Also, break probabilities can be set to 100% in pretty much all situations.

    If you're running over other bugs or if you need help, tutorials or documentation, feel free to contact me :)
     
  5. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    More Bugfixes:
    - Less objects not collapsing properly!
    After several changes in pretty much every part of "DestroyMaster.js", far less pieces will stay floating in the sky without collpasing.
    - Improved link setup!
    I found a massive error in the setup assistent, so now all structure parts will respect their individual "builtDirection". This improves the individual stability of structure parts, makes the whole thing more reliable and saves you a lot of trouble.


    New features:

    After long hours of trial and error, fixing bugs and frustration, I build a new demo scene: The bridge.
    The basement of the four pillars are made from brick, the rest of the construction is a massive steel structure. The debris of the higher brick segements will fade out after few seconds, whereas the lower ones will go static; having too many bricks in a scene just kills performance. The steel construct will desintegrate into several large chunks, which looks pretty good after the last bugfix. Webplayer can be found in the post below.

    Download v4.1

    Download here.

    Copyrights:
    I don't own copyright for all textures and objects in the demo scenes, you'd better use your own textures and sounds! All models used within a construction (steel segments, stone walls, plank walls) were made by me and can be used for free.
     
    Last edited: Mar 6, 2013
  6. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    These pictures show the links between construction parts of the latest demo level:

    (DAMN picture upload not working!)

    ... Anyway... Webplayer:
     

    Attached Files:

    Last edited: Feb 11, 2013
  7. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Is it compatible with Unity 4? I get an error that FixationPoint is not defined!

    Also I cann't see any tutorial!! how could I figure out to use it without a tutorial?

    I need a quick tutorial please!
     
    Last edited: Feb 12, 2013
  8. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Ooooh, yeah sorry :S
    The whole thing was entirely made using unity 4, so no problem there.

    I completely forgot to mention that you need to define 3 tags in order for it to work properly: "ConnectionPoint", "FixationPoint" and "ConstructionPart". All objects called "connect ..." need the tag "ConnectionPoint", these points are used to check wether two construction parts (with tag "ConstructionPart" and script "DestroyMaster.js") are connected. This check is done be checking the angles between "builtDirection" vector and the a vector going from "connect A" to "connect B". "stableLinkAngle" and "stableBaseAngle" then determine wether one part is carrying another one (green lines) or wether it's being carried by that part (red lines).

    Then there's "FixationPoint", a tag you attach to undestrucatible or static objects or rather a GO located where a construction meets some solid ground. The script ("ConstructionSetup.js") attached to the parent object of all construction parts then finds out which objects are especially stable within the structure through these fixation points (can be set up manually in "DestroyMaster.js" by defining the transform "fixture"). Those parts will then display a white line towards their fixation point.

    I'm gonna make a tutorial very soon, since the whole thing has become somewhat more complex than I originally intended. If there are more questions until then, feel free to ask here or just PM me. :)
     
  9. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Ok thanks I will wait for the tutorial then (hope a video tut) I won't play with it without a tutorial coz it seems a little bit complicated to setup without any instructions :D
     
  10. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    In fact, if you want to build something very simple, just assemble the existing parts (plank walls, steel segments or brick/concrete walls) in a shape you like, make all of these objects direct children of one GO that has ConstructionSetup.js attached. Then, disable all booleans apart from "canBreak" and "setupOnStart" (to avoid setup errors caused by the use of prefabs), then set all angle values to something around 45° and set "maxLinkDist" to the average distance between connection points (around 1m for everything exept steel segments, they're normally larger).

    Last but not least, right click "ConstructionSetup.js" on your parent object, select "Setup structure links" from context menu and marvel at the result ;)

    6 steps will suffice for simple vertical constructions.
     
  11. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Thanks I will try this out, and how to add triggers? I mean like that can my setup be destroyed by collision? (only interested in collision :D)
     
  12. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Just select the collider of a construction part, attach the triggers you need to that object, tell the script what destroyer it belongs to (the construction part GO itself) and adjust hitpoints, maximum collision momentum or whatever you need. That's it.
     
  13. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    This means that I need to assign a trigger script to each part child from the group?!
     
  14. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Only those with a collider, yes... How else would you detect if there was a collision if not from the collider itself? I guess I'll add in a new feature in the next version, that somehow combines all colliders/meshs/stuff into one single object too reduce drawcalls, cpu usage and stuff. Although I never quite managed to do that :S
    I guess with a little improvisation, I'll be able to do something like that...
     
  15. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hello again,

    I'm currently working on some kind of "level of detail" for constructions. It's a simple system that enables or disables collision detection of your construction, after whatever event you need.
    For example:
    You want a building to only collapse after the player entered a specific area? Or after you enable a certain option within your quest system? Well then simply call SendMessage("OnEventHappen");, and off you go: The new scripts can either activate or deactivate all collision detection, triggers, etc... by simply disabling all colliders within the structure. Instead, the construction will now use a set of predefined "lower LOD" colliders for collision detection (you'll still want your construction to be accessible by the player or NPCs).

    This is the first step of drastically reducing cpu/gpu use of the destroyable buildings system. I'll have to delete some obsolete parts of the base scripts as well, since those are killing performance too (especially RAM) and fix a last bug concerning link deletion. Also, I might add in a new feature to regroup all destroyed parts into one mesh with only one collider, that would really improve the package.

    Destroyable buildings v4.2 will be out soon, if you want me to add any other features, just tell me about your ideas and I will see what I can do :)
     
  16. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Looks very cool ! It's always great to donate to the community !
     
  17. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Hi KlaRo115,

    I'm currently wanting to make castle walls that can crumble, or be broken at certain points in the wall where say a catapult ball hits the wall. Would your script be able to do this? I just came across your thread today, so I havn't even looked at the code yet or set anything up in my project.

    Would it be possible to do something like a stone wall breaking when a catapult hits it? Thanks.
     
  18. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi Velo222, of course there is a script for that. :) When a wall segment is hit with the corresponding force, it crumbles. The problem is that if you rather need something like a wall where single bricks break out without the wall collapsing immediately, you'll have to wait for a few more days. I'm currently working on this.
    Also, your castle might be pretty large and having active scripts, colliders, etc... attached to every single part will kind of kill your performance and framerates. I have already written a destruction "LOD" (level of detail) for exactly this task, and it'll be in the next update as well.

    At the moment, you can just create stone/brick/concrete walls of any size, that crumble if the necessairy conditions (see triggers) are met and transmit the collapse command to whatever other walls segments you want to rely on the structral integrity of the broken wall segment.
     

    Attached Files:

  19. diegzumillo

    diegzumillo

    Joined:
    Jul 26, 2010
    Posts:
    418
    Hi there :)
    I'm working on a game (for this contest) that needs destructible buildings, and I was already making my own system when I found this! what a convenient moment :D
    Anyway, I just downloaded but I couldn't find any sort of document describing the workflow. Does it have any?
     
    Last edited: Mar 2, 2013
  20. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi, I hope the project will help you. The documentation is missing, because I'm still working on it. :S
    I'll be done about tomorrow evening, since I didn't have a lot of time lately... If you have any specific questions until then, I'll be happy to help
     
  21. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi folks, great news: I finally finished the documentation!

    That means that you'll have much less problems using this project :)
    If there's still something unclear or wrong in this tutorial, tell me and I'll upload a corrected version.

    Download tutorial

    Download package

    (Sorry, no video tutorial for the moment, as I don't have any ok screen recorder for mac.)
     
    Last edited: Mar 4, 2013
  22. JohnPet

    JohnPet

    Joined:
    Aug 19, 2012
    Posts:
    85
    hey, have you ever though of creating destructible cars the same way??? Depeneding on where they are hit and with what force, the cars breaks down, wheels are off etc..
     
  23. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Sure, there's a space ship demo in the package, it shows that the whole thing is also working with dynamic objects and not only with static constructions.

    You might need to make collison detection a whole lot more accurate, since collisions on dynamic (rigidbody) objects are only detected by the parent object, but not by child colliders with a OnCollisionEnter() script attached. You'll probably need a new trigger script to do that.
    Also, the currently used scripts DestroyMaster.js and ConstructionSetup.js are not optimal for this purpose. I'll try to write a solution that fits your specific needs.

    (might however take some time, tons of exams during the next weeks...)
     
    Last edited: Apr 28, 2013
  24. Daniel G

    Daniel G

    Joined:
    Mar 5, 2013
    Posts:
    25
    Yes!! I would love a script like that as well! Thank you :D this is bookmarked!
     
  25. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi, great to see that people are still interested in this project :)
    However, it might take quite some time 'til I get time to actually work on that :S
    I guess I can only get to it in about three weeks, since my finals strat tomorrow and stuff...

    I'll try to work on it as soon as I can, in order to deliver yet another better and more user friendly version. :)

    Greetings, KlaRo
     
  26. delphinius81

    delphinius81

    Joined:
    Mar 6, 2012
    Posts:
    57
    Awesome project! Thanks for putting this together. I think I'm going to use this as part of a storm surge visualization project. Can you comment at all on performance when you have say, 10-20 destructible buildings in the same scene?
     
  27. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi, glad you like it :)

    I haven't quite tried with bigger numbers, but it all depends on your building's complexity anyways. If you have 20 skyscrapers, each composed of 50 construction parts, it will probably kill your performance if there are several buildings (partially) collapsing at once. Espescially the chunking system is pretty cpu intensive, I'd recommend using fewer segements or lower chunk creation probabilites when dealing with 10-20 buildings.
    Also, try to avoid mesh colliders and the like, as they use more cpu than primitive colliders.

    In the end, you might not encounter any problems; my computer is slightly low-end and 2 buildings can cause severe performance loss for me, whereas your computer could handle it without any problems.

    Storm surge simulation? Sounds interesting :) However, the project does not react to forces, but only to collisions or trigger events! You'll have to write a good trigger script to simulate the surge and it's effects with a certain accuracy.
     
  28. delphinius81

    delphinius81

    Joined:
    Mar 6, 2012
    Posts:
    57
    We have some damage models that we'll use to convert any physical forces into a probability function for triggering a destruction event. The hard part will be modeling the force of the waves and wind so we can input them into the damage model. In any case, it's worth a try!
     
  29. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    If your wind and water/wave levels are somehow controlled by a mathematical function or a central structure/script, you could just use those inputs to find out wether the current conditions affecting a building or a construction piece are damaging its structural integrity.
    If you don't have anything like that, maybe let your wind and water control scripts check their impact on a limited number of random parts of a building which are currently being influenced by the weather. If their effect is strong enough, send an external collapse messsage directly to the DestroyMaster.js script of the building or create a trigger script that does this for you.

    I'm definitely gonna update and improve this project again soon.
     
  30. nerf zone

    nerf zone

    Joined:
    Jun 6, 2013
    Posts:
    6
    Hi. If you wish to do the 5th version, could you make an already built modern building like skyscraper and towers.That would be great. Thanks for the great packages. You rocks!
     
  31. christianmanners

    christianmanners

    Joined:
    Jan 31, 2013
    Posts:
    8
    hi there i love the look of this but before i download it... is this like BF3 or is it more cartoony?
     
  32. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi, I'm glad you like "the looks of it" ;)
    I tried to create something like BF3, although I didn't always succeed. From what I've seen from BF, I can say that some parts of my project may be far worse, while a few others (IMO) are more realistic. In BF, you always destroy a couple walls(/structures at a time, until at some point not enough structural elements are holding the higher floors, causing them to collapse. My project is all based on the structural integrity of the single parts of a building. Once a wall crumbles, all elements which are strictly relying on this one element collapse as well.

    Also, Destroyable buildings v4 can be pretty laggy once too many things break/collapse at once, but with a few tweaks and a little moderation/triggering/LOD-system, you can do amazing damage at relatively low performance cost.

    However, there are still a few bugs in there, mostly concerning the "chunk creation", where several parts of a building are united into one large chunk that breaks out of the structure and definitely looks awesome on tall buildings ;)

    I hope that answers your question. Maybe just download the package and check out the demo scenes, they might tell you exactly if it's the right thing for your project.

    News: By the way, version 5 is on its way, without those little bugs, less performance loss. It's currently in alpha state, including some new features and much more ease of use. I tried automating the setup as far as possible, so the end-user won't be bothered by too many variables and settings.
     
  33. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    127
    Really nice man. nice to that you are giving it away free :) destructions look really nice but i didnt get it working doing models my self but keep up the good work bro! :)
    waiting for video tutorial :)
     
    Last edited: Nov 26, 2013
  34. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi again,
    sorry for letting you wait. I can´t give you a video tutorial yet; it´s been quite a while since I last used version 4 myself :S

    I can however give you a few more details on V5:
    I changed the whole setup into several categories: As with v4, there´s still the master script coordinating the destruction of each construction piece (CP); this will tell if a damage trigger input is sufficient for a collapse of the respective piece. Eventually, the destruction of a piece will be forwarded to all segements relying on this CP. If its structural integrity is no longer granted, it will collapse as well, probably leading to total destruction.
    Just like in the previous version, there are trigger scripts which will identify any damaging influences from the outside. They´re easy to code by yourselves and allow you to modify/extend the project with ease. They can react to anything you like, ex.: damage, SendMessages, Collisions, Triggers, etc...
    Then, there are the destroyers, which will allow you to generate a collapsing effect that is different from the standard built-in replacement of a broken CP. Chunking behaviour has been transfered to ther destroyers and is no longer a default destruction within DestroyMaster and now uses physics and joints to simulate more realistic behaviour and avoid weird collision/parenting bugs.
    One new feature is the implementation of modifiers; those tools will automatically change the looks, behaviour, collider or mesh shapes of any CP. If you´d like to add in burning segements falluing off the structure, you´d probably use a modifier to do simulate this. Modifiers can have different effectrs and can even be combined with triggers, to let you create immediate crumbling effects based on fairly realistic input values and withouzt having to bypass through the DestroyMaster.
    Last but not least, collapsing behaviour is made easy using "substances"; those are prefab construction materials which tell you what properties a material has once something influences it. Most of the variables from previous versions are now automatically setup using those material properties.

    Also, a lot of useless or buggy scripts and functions have been erased, replaced, rewritten or extended to reduce overall performance cost and make the package more reliable. Several scripts are included so you can get started destroying stuff right away with far less effort (and less documentation needed).

    I hope to be able to release V5 during the next 2-3 weeks, so stay tuned.
     
  35. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    happy holidays! very nice! thanks!
     
  36. stefanob

    stefanob

    Joined:
    Nov 26, 2012
    Posts:
    67
    Any news on v5?
     
  37. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi, well yes, there are some news ;)
    I'm still working on the project, but there are still a few very annoying bugs I can't seem to get rid of. So basically it's all working and the toolset can be applied to most any object in most any situation, but it's not quite as reliable as I want it to be. Especially the chunk creation and mesh deformation don't look as good as they should.
    I removed the unnerving floating chunks bug, but the debris clusters are not rigid enough and don't repond to collisions the way they should. It's a bit of a pain sending around several packages of data while at the same time trying to keep things as simple and user friendly as possible. I'll try to do some more bug fixes and hopefully I'll be able to share a beta version tomorrow or monday.

    Okay, as I was writing this, I managed to complete the script that automatically creates the connections between different construction parts. Looks like the only real issues remaining are chunk creation and one of the modifier scripts. Maybe I'll add in another example scene featuring a crashing car or something in the like.
     
  38. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi folks,
    Sorry for letting you wait yet another day, but it was kinda worth it, since I could remove most of the bugs I was talking about earlier on.
    So basically, this is it:

    Destroyable Buildings V5.0 beta

    You may not have noticed it, but that little "beta" in the title means that if you stumble across any bugs or things are not working out for you, just ask me for help and I'll try to fix this as soon as possible. Version 5 is still work-in-progress, and it's mostly about the fake physics and awesome collapsing effects, not about the simplistic visuals of my demo levels.

    The package contains game-ready scripts that will allow you to destroy most anything in most any possible way. this specific version has been optimized to be extremely modular. Of course you can still use all the scripts you may recognise from earlier versions, but keep in mind that they can now be combined to create much more diversified destruction effects. The destroyMaster and triggers may be sufficient for your game, but just imagine what players might think if their car crashes into a wall, losing its doors while the whole front section of the vehicle is compressed into an odd-shaped pile of trash. ;)

    Another reason I call it a beta is that I'm still not quite confident about chunk creation. The debris clusters are often very loose and there happen to be gaps between single pieces (although using joints to tie them together mostly fixed this issue). If you think this or other scripts don't meet your expectations or are not reliable enough if it comes to good looking mass destruction, send me a PM or ask me here, I'll do my very best to rewrite or fix those scripts. :D

    Also, I'll have to write a new documentation for this version, until I do that, I probably won't create an own threat on the forums or upload it to the asset store.

    I'm waiting for your feedback and I hope you'll enjoy Destroyable Buildings V5 :)

    Download DB V5


    PS: Scripts coming from previous versions are not compatible with V5! However often it's just a work of minutes until they match again. If you miss any of the old features I forgot about, just let me know.
     
  39. milanm

    milanm

    Joined:
    Mar 8, 2014
    Posts:
    2
    Hey KlaRo115,

    This package is pretty sweet I converted the scripts to c# only because i prefer the language. Let me know if you want it and ill send it to you.

    I have a question regarding your brick wall scene. I have been trying to come up with a way to make a large wall destroy-able, piece by piece and eventually all fall, but the physics calls are really slowing the game down. You haven;t posted anything new on this threat in a while so i don't know if you are still working on this stuff or not. If you are, do you mind i shoot you an email with a more in depth outline of my problem and what i have tried. You seem to have a very good grasp on how this stuff should act and the fact that your code barely uses the physics resource for the amount of stuff being destroyed on the scene is awesome.

    Thanks again,
     
  40. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi,
    thanks for the reply; I was waiting for some feedback, but appearently there were no complaints, so I went on to some other projects I had in the making.

    In version 4, I really worked on the brick wall thing you're talking about, but I couldn't figure out a good way of doing it, since every time, performance drops drastically. I even started considering solutions for this specific problem back in version 2, but I kapt getting the same results. If you're not very familiar with procedural mesh generation, doing this is really hard and the only solutions I could think of so far were not satisfying on larger scales. :S

    In the end, I left this example out and added in some other features for version 5 (modifiers and deformation). I have to say now - several weeks after releasing it here - that I'm not sure chunking and collision detection are done in a very good way. I'll have to rework that once again for the next version, since those upgrades really require rewriting many parts of the package.

    Slowly, I'm getting the heck of how the whole thing should be done, but it's quite complicated to keep stuff user friendly and reliable at the same time. Since I'm not an engineer and I don't know how to do all of the correct math, I'll have to stick with basic physics and solutions that may look good, but are plain incorrect (physically speaking) and use tons of user input. The water physics scripts for example were written 1 week before we had fluid physics in class. :rolleyes: So basically, water resistance, friction and surface tension are a huge pile of c***. They're just not working for every mass, entry velocity and object size.

    I'd have to rewrite the package a 5th time to get rid of all of those deficient solutions. The main idea behind Destroyable Buildings project was to create fully destroyable environment without having to play around with tons of settings and doing stuff manually. It was designed to save time, but it still needs way too much fine tuning.
    I'm working on it and trying to find better ways of solving known issues. If you happen to have any ideas, requests or questions, feel free to ask me here or via PM. :)

    ps: Maybe you could post a link to the c#-versions here, so other people may enjoy it as well? I'm not so much into c#, so I'll probably stick with JS. ;)
     
  41. milanm

    milanm

    Joined:
    Mar 8, 2014
    Posts:
    2
    I definitely think you are on the right track. A lot of your scene demos have a realistic physical feel to them.

    I am creating structures from the bricks through code. Currently creating only one structure in the scene. My problem is, with rigidbody attached to each one and the physics engine constantly working the game slows down a lot, to about 3 - 5 FPS. I reduced this by always having isKinematic on and only turning off isKinematic every time something has changed with the structure. The code does a quick check makes the proper changes accordingly. But if majority of the structure is damaged or bricks missing I have code in place to turn off the kinematic for the rest of the bricks left in the structure which in turn causes a cascading affect and the building falls down. When this happens the game slows down to about the same 3 - 5 FPS. I have reduced the amount of bricks by half on the screen and increased their size to maintain the size of the building. I am now working with just over 800 bricks in one structure and when the building collapses it dips to below 10 FPS just for half a second then returns to about 60 - 70 FPS. Which is much better than what I have been working with but still not great. Especially since the blip in FPS is noticeable.

    I liked how you replaced a single object with several smaller objects (bricks) when it had a collision, but unfortunately that method wont work well for entire structures (from what I have tried to implement anyway). It would work if you wanted the entire structure to collapse from one hit but not if you wanted it to collapse if for example half or part of the structure was missing. I wanted to see if you had any ideas of making your method work more how I want it to work or another method that you have thought of but haven't tried. I have been through most of the forums regarding physics slowing down games to see if I can incorporate a solution from someone else's problem, but I have had no luck. So any suggestions you may have would be greatly appreciated.

    Thank you,

    P.S. Yes i will definitely post a link with the c# version of your scripts.
     
  42. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Thanks, I tried adding as many correct physical formulas as possible ;)

    Yeah, I did something very similar to your isKinematic-thing back in version 2 of my project, but I stumbled across the exact same performance loss. In v4, I tried reworking this, but only for whole wall segments. I think I included the DebrisSetStatic script in version 5, since it mostly solved the physics problem by removing rigidbody after a certain amount of time. Back in version 2, I already tried something in the like and ended up getting very interseting results. I think I'll have a look at this particular problem again. Also, I took a look at some procedural mesh generation lately and it gave me a couple ideas of how to do the trick without having to use sKinematic in the first place and starting from a single mesh.

    Also, I tried reducing the amount of rigidbodies in scene by integrating the chunking system, however this idea became kinda obsolete with version 5, since I went over to using rigidbodies and joints again. As I already mentioned, I'll have to rewrite the whole collision and chunking system to further improve overall stability and reliability.

    I'll have a look at the whole stuff again as soon as I can, but please keep ion mind that v5 is only in beta state so far; many things and even the whole base script set may still change.

    Anyways, thanks far the feedback and for your ideas, I'll start a new thread for the final version of v5 once it's ready. :)
     
  43. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    By the way: I kinda got into it again and immediately started rewriting DestroyMaster.js. Then follows the collision system and finally the regular triggers and destroyers stuff. I'll add in my ideas about the brick wall problem as a modifier script. ;) (has to be a modifier to keep it consistent with the rest of the project)

    If you happen to have any more ideas, requests and/or feedback, go ahead and ask me :)
     
  44. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi again,

    After working on version 5 beta, it rather ended up as a great full version, instead of another intermediate one. Sounds like a lot of progress? It's not :(

    I figured that some of the script which now is so much more reliable than ever before, especially when it comes to dynamic destroyable structures. I built an awesome demo scene with a wooden ship (really water physics this time :D ), when I noticed that my current approach was far from perfect. The currently used concept of superior and inferior construction parts has just become obsolete when it comes to boats, chunks and most anything except for bridges and towers. Since I focused on building these for most of my previous demo scenes, I never really noticed this issue (except for a wooden gate in v4).

    I pretty much stopped working on v5 and immediately went on to rewrite E-V-E-R-Y-T-H-I-N-G. This means that Destroyable buildings version 6.0 is on its way and looks very promising so far! :)

    This radical change in concept might make a lot of things so much better and grant you yet again more reliability. It allows for such things as destroyable buildings, structures, cars and vehicles. At the same time, chunk destruction is getting much better and the individual clusters will actually break if triggered again.

    In short:
    - More reliable, less bugs.
    - Wider range of use.
    - Better chunking behaviour.
    - Easier setup.

    All previous features will of course stay and be upgraded or extended, such as to give you total control over your completely destroyable ingame environment. As always, if there are any requests, ideas or questions, go ahead and send me your feedback. ;)
     
    Enrico Monese likes this.
  45. One of the best assets ever made!
    Can't wait to see v6!
    Keep up the good work man!
     
  46. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hey Enri1997,
    I'm glad you like my stuff, but sadly, I can't share a whole lot of good news right now. :S

    May initial concept for version 6 was right, but I ran into several scripting errors and obstacles I simply couldn't surpass. At some point in mid april, I stopped active development on v6, because I didn't find any decent solution for the bugs I encountered. To make it short: Once you had about half a dozen CPs, unity would insta-crash due to some kind of overflow exception. It took me a while to figure out what that even meant, and I only found a possible solution last week.

    Once again, I'll have to rewrite the whole thing, add in some kind of collapsing protocol (ordinary SendMessage just won't do it anymore) and start working with scripting classes (something I only have very little experience with). So far, I managed to keep the older scripts (destroyers and triggers) relatively compatible with the newer versions, but that might change with a future update.

    The scripting itself will not be very hard, but it's a real pain to design the whole destruction process in the first place. As always, I will try and keep stuff as simple as possible, both to reduce performance cost and to make it as modular as possible.

    Also, since I gotta start from scratch anyway, new ideas and feature wishes are welcome. ;)
     
  47. Smartline-Games

    Smartline-Games

    Joined:
    Aug 15, 2013
    Posts:
    67
    Dear KlaRo115,

    Would you be so kind to upload the source project of the Destructible bridge?
    Thank you for your understanding, and we're hoping to hear from you as soon as possible.


    Smartline-Games
     
  48. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi again,

    Here's the download link for v5f, chunking is a lot better for larger structures and I included decent water physics, however those tend to lag if too many objects are floating.
    Download v5f

    Version 6 won't be ready to be deployed any time soon, unless I completely rewrite it, but I should be able to share a beta version within the next two weeks. And as always, if you encounter any problems, feel free to ask for help. :)

    Greetings, KlaRo

    edit Feb2017: Download links updated.
     
    Last edited: Feb 23, 2017
  49. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm going to be starting a little mech game with my younger son, whose imagination is really caught by that sort of thing. So I did a quick search for destructible buildings in Unity, and this thread popped right up!

    It sounds like you've done a lot of really great work there. I'm going to try version 5f tonight, and just thought I'd say "thanks" and offer some encouragement on that version 6. Keep up the good work!
     
  50. ariusdb222

    ariusdb222

    Joined:
    Jan 25, 2015
    Posts:
    88
    This is really great, now i know how to go about fixing, and even replacing some of my scripts... Thank you very much!!:)