This article relates to the game "Half-Life: Alyx". Click here for more information.
This article relates to the workshop tools for "Half-Life: Alyx". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Half-Life: Alyx Workshop Tools/Modeling/Breakable Props

From Valve Developer Community
Jump to: navigation, search

Note.pngNote:This tutorial assumes a basic familiarity with ModelDoc usage as established by the earlier tutorials.

Create a Physics Prop

Start by creating a simple box physics prop out of primitives.

This tutorial uses primitive shapes for rendering and physics, but references to mesh files (.fbx, .dmx) can be directly substituted. Import filters make it easy to create a single FBX file that contains many mesh parts that can then be referenced by separate breakpieces.

  • Add RenderPrimitiveBox and PhysicsShapeBox nodes with origin (0,0,8) and dimensions (16,16,16)

Breakable Props-132120844.png


  • Apply the 'prop.wood_box' surface property to the physics box

Breakable Props-132120843.png


  • Add a prop_data node to indicate that this model is intended to be used as a physics prop.
  • Now use the ModelDoc game preview to verify that you can spawn the model as a prop_physics and move it around

Breakable Props-132120848.png

Breakable Props-132120850.gif

Add a BreakPiece

  • First edit the prop_data to specify a health - this will allow the prop to take damage and break if it has any breakpices:

Breakable Props-132120852.png

  • Add a BreakPieceEmbedded node - this node will contain everything required to have a simple breakpiece without authoring it as a separate model.
  • Under the BreakPieceEmbedded node, add a RenderPrimitiveBox and PhysicsShapeBox with origin (0,4,8) and dimension (15,7,15) - you can do this by copy-pasting the boxes you created earlier.
  • For clarity assign the renderbox the primary_red.vmat material so it's very clear when the object breaks.

Breakable Props-132120862.png

Breakable Props-132120864.png

Breakable Props-132120865.png

Each BreakPieceEmbedded node is effectively a small embedded sub-document that can contain most nodes. (NOTE: Due to a limitation in the editor it may warn about some nodes but most will work just fine.) When the parent model compiles, each BreakPieceEmbedded will be extracted and compiled into a separate vmdl_c that is then referenced by the parent model's break info.

Add a Second BreakPiece

Breaking something isn't very interesting if it only breaks into a single piece. Right-click your BreakPiece and select "duplicate" then change the origin of the new boxes to (0,-4,8)

Breakable Props-132120863.png

We made breakpieces slightly smaller than the original box in order to guarantee that they don't overlap when they're spawned. The physics engine is fairly resilient in the face of overlapping objects, but it's always better to avoid when possible!

Test Your Breakable

Use the game preview to spawn a prop_physics and use the shoot tool to verify that it takes damage and breaks as expected. Congratulations, you've made your first breakable model!

Breakable Props-132120867.gif