In this example, we will use the wooden_barrel_simple
asset created earlier in the chapter. Alternatively, you can open the example file objectswooden_props wooden_barrell_destructible.max.
To create a .cgf
containing the object's broken pieces, we must create them as submodels for our main mesh. Each submodel must also have a physics proxy geometry. The submodel's name and User Defined Properties will determine its behavior.
The remain model will be used as the permanent, post-destruction submodel, which replaces main when the destroyable object's entity state changes from alive to dead. You could also add a new, destroyed submaterial and assign it to this mesh as a destroyed texture may appear drastically different.
If no node is named remain, then all the pieces other than main will be destruction pieces, which are physically dynamic.
0
,0
,0
for all the pieces.Note that, when the object is destroyed, the pieces spawn in the position in which they were placed in the CGF, relative to the original model, and can be physically simulated as seen in the following screenshot:
You can use this destructible object for many different functions now as it has two different physical states, an alive state or a dead state. In the alive state, the object acts precisely like you'd expect a normal physical entity to react. It can be set up to be a rigid body or static physical entity. Some fun examples are cliffs, platforms that the character might walk on, bridges, buildings, and so on.
After taking more damage than the specified Maxhealth, the entity will go into the dead state. When going into the dead state, a destroyable object entity can optionally generate a physical explosion and apply area damage to the surrounding entities. It can spawn a particle effect, and finally replace the original geometry of the entity with either the destroyed geometry and/or prebroken pieces of the original geometry. When the object breaks due to a hit from a projectile, this hit impulse is applied to the pieces, in addition to any explosion impulse that occurs on the entity.
There are a few different types of destructibility available in the CryENGINE. Try using some of the other types of destructible objects available.
Similar to static and simple objects, some parameters can be added to the individual objects in a destroyable object asset. Try adding some of the following User Defined Properties to the pieces from the preceding example:
1-var
to 1+var
.Using 2D, breakable objects is a useful technique for level objects, such as glass, ice, wood, or walls, which typically don't have a lot of volume or thickness. The technique works very well with thin and mostly flat mesh objects.
Two-dimensional breakables are controlled through the surface type of an object set in its .mtl
file.
Some surface types have been specifically set up for two-dimensional breakage already within the CryENGINE Free SDK. Some of these are mat_glass, mat_glass_breakable_safetyglass_large,and mat_glass_breakable_thin_large. Some rules for objects using these surface types are as follows:
For example, this type of breakability within the CryENGINE can be seen in the following screenshot:
Breakable objects are also sometimes referred to as jointed breakables. These are structures that are built of separate meshes being held together by virtual joints; rather than having submodels spawn on destruction, all the pieces are already rendered.
You can create these within 3ds Max or, alternatively, use a very useful CryENGINE entity called a constraint.
A constraint can be used to hold two physical objects together. The parts can then be individually disjointed by applying physical force greater than the joint limits, by using objects such as a gun, or by player interactions such as explosions and so on.
Some good examples of breakable objects are road signs, wooden fences, or a wooden shack. All these assets are made of parts that are assembled as they appear in the real world, as seen in the following screenshot:
For furniture or anything that doesn't require a base attached to the ground that remains after it's broken, it is better to use a rigidbodyEx or basicentity. If you need the remaining part to stay static, then it is better to use a breakable object and specify the mass of the part as 0
. If this isn't done, the engine will determine at random which part remains as the static object.
.chr
.cga
.cgf
.cpp
.mel
scripts18.226.165.131