Hi guys im trying to make my surrounding environment destructible in an fps im working on in unity3d, similar to the way the old red faction system used to work on playstation 2. Does anyone know if this is possible and easy enough to do in unity as i may have to switch to another dev kit or engine if it cant do this. Thanks in advance guys.
If you’ve ever played red faction the levels were huge and you could blast through miles of rock and that was on PS2 and the performance was good, i was really hoping that it would be available as a feature in unity.
Possible, yes. Most things are in Unity. Easy…that depends on your skill level and what you want to achieve, but probably not. There’s no “make my environment destructable” button if that’s what you’re looking for. You could take a look at some of the destruction/slicing packages people have made, or try and do it using the physics system or a voxel system.
Thanks for the replies so far guys! Ok i have never used a voxel system before so maybe you guys could explain a bit more about that for me. I was thinking of making walls from sliced models in 3ds max sliced into triangles then imported in as one model but setting each to be rigidbodies but i would thinking that would be way heavy on the engine in terms of physics. ideally i want to be able to tunnel through a say 100 yard wall navigating through it as i please with a mining gun. Any further ideas? I would rather have the animations come off as dynamic or non physics objects but without having to make loads of small bricks that have particle effects on death or kill animations.
Red Faction used an engine called ‘Geo-Mod’ (made specifically for the purpose of modding geometry) for their first two games, until they created their own for Red Faction: Guerrilla.
Its a very specific feature, available in only very specific engines. But it is certainly possible in Unity with a fair amount of searching and scripting (mainly mesh deformation for knocking holes in rock) or joints/2 models (whole+broken) to break individual objects
That would kill any engine. Minecraft doesn’t store all those blocks. They are all one mesh (maybe a few) but he does an exceptional job making it seem separate.
Thanks Dman, do you happen to have any links to examples of mesh deformation in unity? Also i havent experimentd with joints yet i could really use some references if you have any please?
I’m not sure how I would go about doing this in Unity, I’m sure you could script it in per usual though. It would probably be quite a feat to make something like Geo Mod engine as a scripted package.
The Boolean operation method is a simple enough theory, its just a matter of implementing it.
Since I am doing something like that right now, I can say it is definitely possible and it is running reasonable well even if you blow the crap out of the environment. The big issue with Unity is not so much destruction, the big issue are the fragments. They will trash the rendering pipeline if you don’t do some real nasty scripting and complex batching yourself… Currently I have it running with up to 100k fragments lying around and about a few thousand can fly around at the same time. But that is almost all I can get out of Unity. For more you will probably need C++ and a more direct access to the pipeline. As long as the fragments are idle, they are only limited by RAM so far… Just the amount of flying or moving particle, thus physx powered, it rather limited… Especially since Unity does not seems to utilize more than one core… I hope this changes with 3.5
Never thought of that frankly ^^. I was just coding it for my upcoming game…
Maybe if here are people who really need this stuff you could describe your situation so I can figure out how to design the interface for that or if it can be done that way at all. Currently it is all highly optimized for my purposes, so it might not be well suited for everyone else…
The facts so far are:
fragments can be shaded with multiple textures, and can be transparent. But you will have to derive your own shader or use the one I have written, since the Unity shaders are not suitable.
works with deferred rendering
supports so much fragments as the RAM allows ^^
and if I optimize a little more I hope I can also push the amount of flying particles to be limited only by PhysX
i think for the most part the flexibility would be the biggest factor, when I was considering something like this I was thinking of a collision manager script that would read weather or not the projectile type is allowed to deform applicable objects within the ‘splash damage’ radius of the collision point and if so then execute a breaking script for the type of impact that weapon has.
Seems like if it were that simple to organize then it would be packable pretty easily. Working shader templates would be handy to the extent they’re needed.
I’d be interested in it and I think plenty of others would be too.
I thought the application for that was to destroy the entire object, I think what we’re looking for here is more like “blow a hole in something while it remains in place”
The easiest and probably the only way in Unity is to make pre-made destructable objects. This means that you will have to struggle with breaking of models in 3d modeling package and also assigning proper textures on broken parts. Its a lot of additional work. You must really think again if you really need destructable environment, to me as player it never played any noticable note in overall gameplay.
If you want procedural and easy to make destruction and if your game really relys so much on it use UDK instead.
Yes because like with much things AAA titles do is just to throw in some candy but still suck at gameplay ^^. Destructible environment only makes sense if it is actually part of the gameplay especially when you have to put so much effort into it. In 5-10 years nobody will even talk about this, everything will blow up automatically ^^.
Have you actually used UDK? Its not like changing clothes… I had the same thought when I was at a point to give up with destructible environment. Now it works in Unity and I can only be happy that UDK seems to suck in almost every aspect except of AAA features… Otherwise I may have taken that troublesome road to nowhere. For UDK you really need a professional team, everything takes at least 10 the time there is nothing good then about getting destruction (almost) for free, you still have to configure it and it seems to be as daunting as everything else…Not to mention the fees…
It depends. As far as I know all AAA title are currently using prebaked destruction. The reason is that generating “good” fracture data is nothing you can easily do automatically at the moment… Its artwork too.
What you want is probably more what I am doing, automatically generate destruction data ^^. I heard Battlefield 3 is also using something like that since they were complaining that always the same pieces of rock fly around. That would be really lame for a AAA title, even the thing I am working on doesnt bore me with same fragments ^^…
There are some simpl(ish) ways to cheat the effect as well. Assuming you’re importing your meshes as seperate entities (seperate walls, doors, etc.), you can calculate where bullets or melee attacks land on the environment, then instantiate some sort of texture at those locations, ie. bullet holes. Assign a damage script to each destructable object, and after it has sustained enough damage, destroy it, probably by replacing it with destroyed terraform or several.