S&box Wiki

Revision Difference

Breakpieces#545853

<cat>Dev.Model</cat>⤶ <title>Breakpieces</title>⤶ ⤶ ⤶ #Introduction⤶ ⤶ Breakpieces are dynamic pieces that spawn once a prop is destroyed by any of several types of damage. In an organic context these may also be referred to as "gibs".⤶ ⤶ #Making a prop destructible⤶ ⤶ Common to the setup of any type of breakpiece, a prop needs to first be made breakable before breakpieces can spawn. This is done by the means of Prop Data in ModelDoc:⤶ <upload src="4e91c/8d976cc8b83166b.png" size="4654" name="adding_prop_data_node.png" />⤶ Once the node has been added to the tree, it can be edited in the following fields to receive properties of destructibility:⤶ <upload src="4e91c/8d976d04d9d15b8.png" size="18873" name="editing_prop_data_node.png" />⤶ <note>Currently, it is unclear how some these properties relate to each other. Anybody with added knowledge of these properties should add to this page over time!</note>⤶ Note the properties that are highlighted in **blue**, as these are changed from their default value to reflect a limited health pool and the prop's tolerance towards damage caused relative to its speed at an impact. The current values represent the tolerance of a prop that is able to sustain 2-3 high speed impacts, as the prop is repeatedly flung with the Physics Gun, at reasonable effort, into the ground. Subsequently, you may want to edit these values to represent a prop that is either more durable or less durable.⤶ <upload src="4e91c/8d976cfe400a894.png" size="11131" name="compiled_prop_data.png" />⤶ For additional context, you may also open an existing compiled breakable citizen prop, such as the watermelon, in order to observe the necessary properties of a destructible prop.⤶ ⤶ #Adding breakpieces to the prop.⤶ ⤶ Breaking the prop in the current stage of setting up will simply cause it to disappear. This is where breakpieces are needed.⤶ ## BreakPieceEmbedded⤶ <upload src="4e91c/8d976da70ce4763.png" size="963" name="image.png" />⤶ Breakpieces can be **embedded** into your model, which will correspond to the individual model files that you choose (.fbx, .dmx, etc.). This process is easiest automated using the *Add Break Pieces From Mesh* wizard:⤶ <upload src="4e91c/8d976d26017c9a0.png" size="48890" name="image.png" />⤶ After doing so, you can then edit each breakpiece from the node tree. This will allow you to set any unique properties for each piece such as the surface property:⤶ <upload src="4e91c/8d976d354b7e4f9.png" size="22362" name="image.png" />⤶ <note>While you are able to preview embedded breakpieces after compilation, you cannot edit them as any .vmdl file because embedded breakpieces do not receive a .vmdl of their own. They are seemingly compiled from preset instructions and automatic PhysicsHullFromRenders. It also delimits the use of LODs.</note>⤶ The default naming scheme for each breakpiece after completing the wizard is *piece_0*, *piece_01*, *piece_02* and so forth...⤶ ⤶ These will ultimately result in the compiled files *piece_0.vmdl_c*, *piece_01.vmdl_c*, *piece_02.vmdl_c*, etc...⤶ ⤶ | Breakpiece node name | Compiled breakpiece filename |⤶ | - | - | -|⤶ | piece_0 | *piece_0.vmdl_c* |⤶ | piece_01 | *piece_01.vmdl_c* |⤶ | piece_02 | *piece_02.vmdl_c* |⤶ | ... | *...* |⤶ ⤶ When the model is compiled, the embedded breakpieces will generate into a folder with the same name of the .vmdl you are working on, if they have not already. Their names reflect the same as above, unless you rename the nodes before compiling.⤶ ⤶ At this point, your prop should have capable breakpieces that spawn once the prop is destroyed, and you can finish your work off here if you wish. However...⤶ ## BreakPieceExternal⤶ <upload src="4e91c/8d976de44da45aa.png" size="927" name="image.png" />⤶ The customization of embedded breakpieces is limited to the properties of each node. For applications with props that break into a considerable amount of breakpieces at once, it may be very taxing on performance when the prop is destroyed because the embedded breakpieces do not allow for separate LOD functionality, even if broken from far away.⤶ ⤶ To get more control of each breakpiece, you can set up additional .vmdl files that only represent the breakpieces **externally** and then refer to these using BreakPieceExternal.⤶ ⤶ You need to create standalone props of the individual pieces ahead of time, with appropriate nodes within, and then refer to these using external breakpiece nodes:⤶ <upload src="4e91c/8d976dc1c3f9dde.png" size="105179" name="image.png" />⤶ Notice how some properties have disappeared from the list when compared to the embedded node, as these are now handled within the Model that is being referred to at the bottom of the property list.