Counter-Strike 2 Workshop Tools/BreakableWindows

From Valve Developer Community
Jump to navigation Jump to search
Note.pngNote:This tutorial assumes a basic familiarity with ModelDoc Editor.
Icon-Bug.pngBug:func_breakable does not spawn gibs on break in Counter-Strike 2 Counter-Strike 2. It's recommended to use prop_dynamic instead  [todo tested in?]
Warning.pngWarning:Window can only be in shape of a box.
Todo: add screenshots with in depth explanation

example model can be found in 🖿Counter-Strike Global Offensive\content\csgo\workshop\content_examples\breakable_glass\breakable_glass_01.vmdl

model doc outliner setup for breakable glass

Making base window model

Tip.pngTip:it is not needed to have custom model file since primitive shapes are created inside of ModelDoc

Adding a root node

  • add RenderMeshFile to model, cancel the file selection and press Keep on popup , It should appear as empty node, change RenderMeshFile Name to something like "window". This would be used as root node to add modifiers as child later. It should have the following parameters in inspector:

RenderMeshFile

Property Name Value
Name window
Source file <none>

Adding box primitive

  1. add Mesh Operation Stack node as parent of RenderMeshFile
  2. add Box Primitive as child of Mesh Operation Stack , set desired `Box dimensions` (x-thickness,y-width,z-height), but keep `Position` at [0,0,0], for this example, use 🖿workshop/content_examples/breakable_glass/breakable_glass_01.vmat material
  3. add UV map planar custom stretch it so only single part of window texture fills model (you need to unselect this node and compile to preview how uv will look)
Icon-Important.pngImportant:Model should be facing forward in X+ direction.


Adding physic properties

PhysicsHullFromRender

  • add PhysicsHullFromRender with following properties:
Property Name Value
Surface Property glass
Collision Property window

prop_data

  • add prop_data with following properties:
Property Name Value
Base Prop Glass.Window
Allow As Static Prop yes
Health 1

This will make sure that the prop can be used as prop_physics

Adding Break pieces to model

Base setup

Broken glass shards are done procedurally inside of modeldoc, to do that:

  1. add BreakPieceEmbedded to model.
  2. set the following properties:
Property Name Value
Ragdoll Applies Bind Pose Root no
Collision Group Debris
Fade Time 3
Essential Piece yes
Material Group Mode Inherit Material Index
Spawn Piece Motion Disabled yes
Piece Health Override 0
Note.pngNote:It will show an error and will not let you compile the model, this would be fixed by adding RenderMeshFile.
  • add empty RenderMeshFile as child of BreakPieceEmbedded same way as described in 1.1 of this tutorial, error should disappear. Name it something like "window_broken"

Creating shattered glass model

RenderMeshFile

Property Name Value
Name window_broken
Source file <none>
  • Add Mesh Operation Stack as child node

Now add the following operators to it:

Voronoi Plane Primitive

Uses voronoi noise to slice model

Icon-Important.pngImportant:Сopy Bounding Dimensions from box primitive created earlier.
Icon-Important.pngImportant:Glass material should have dynamic expressions configured, otherwise there would be no break pieces.

Example configuration

Property Name Value
Bounding Dimensions [Copy from box primitive, leave x=0]
Material

🖿workshop/content_examples/breakable_glass/breakable_glass_01_broken.vmat

Number of Points 64
Random Seed 2
Weld Distance 0.5
Bias to Center 0.1
Shrink Pieces 0
Extra Border Points 1
Add center Vertex no
Inflate

Create Inflate as child node, used to give thickness to glass shards

Property Name Value
Inflation Amount 0.75
Build Sides yes
Build Backfaces yes
Todo: Box Select/ Vertex sine wave for distortion


Select All
Assign Vertex Pivot Data

Used to assign material expressions to break pieces

Todo: Explain material creation

Creating custom glass material