Prefab: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Provided reason.)
m (Corrected mistake: Ctrl, not Shift.)
Line 6: Line 6:


# If this prefab is intended to interact with named objects inside itself, such as a button that triggers a door to open, place "_&i" at the end of each object's name so that the prefab can be used several times within a map without the individual prefabs activating each other.
# If this prefab is intended to interact with named objects inside itself, such as a button that triggers a door to open, place "_&i" at the end of each object's name so that the prefab can be used several times within a map without the individual prefabs activating each other.
# Select the objects you wish to include in your prefab (using <Shift>-click).
# Select the objects you wish to include in your prefab (using <Ctrl>-click).
# If you plan on inserting the prefab using the [[Entity Tool]], the origin (0,0,0) of your map will be used as a reference point to where you insert the prefab, so it is advisable to drag the selected objects to this origin and centering the prefab on it.
# If you plan on inserting the prefab using the [[Entity Tool]], the origin (0,0,0) of your map will be used as a reference point to where you insert the prefab, so it is advisable to drag the selected objects to this origin and centering the prefab on it.
# Either click the '''Create Prefab''' button in the [[Hammer New Objects Toolbar|New Objects]] toolbar, or select the '''Create Prefab''' command from the [[Hammer_Tools_Menu|Tools menu]]. (Shortcut key: <Ctrl>-R)
# Either click the '''Create Prefab''' button in the [[Hammer New Objects Toolbar|New Objects]] toolbar, or select the '''Create Prefab''' command from the [[Hammer_Tools_Menu|Tools menu]]. (Shortcut key: <Ctrl>-R)

Revision as of 13:42, 4 August 2006

A Premade Fabrication, or Prefab, is a separately saved object, usually consisting of multiple parts, either brushes, props, or entity elements. The prefab system allows you to easily store pieces from your levels that can be used repeatedly. Examples of useful prefabs include hallways, pillars, special entity setups, etc.

Prefabs are simply small map (.VMF) files that contain only your prefab. These files are stored in a particular prefab folder, generally \sourcesdk\bin\prefabs, so that Hammer can find them and allow you to easily insert them into your levels. Prefabs can be organized into their own heirarchy in the /prefabs directory - Using a folder of prefabs for each map, mod, etcetera, as determined by the user.

How to create a prefab:

  1. If this prefab is intended to interact with named objects inside itself, such as a button that triggers a door to open, place "_&i" at the end of each object's name so that the prefab can be used several times within a map without the individual prefabs activating each other.
  2. Select the objects you wish to include in your prefab (using <Ctrl>-click).
  3. If you plan on inserting the prefab using the Entity Tool, the origin (0,0,0) of your map will be used as a reference point to where you insert the prefab, so it is advisable to drag the selected objects to this origin and centering the prefab on it.
  4. Either click the Create Prefab button in the New Objects toolbar, or select the Create Prefab command from the Tools menu. (Shortcut key: <Ctrl>-R)
  5. A Save As... dialog will open, displaying the Hammer prefabs directory. Type in the filename to save your prefab as and click the Save button.
  6. The new prefab will now be available for insertion in the New Objects toolbar.

For information on how to place prefabs in a map, see Inserting Prefabs.

External links

Various sites that host custom made prefabs and models: