Prefab: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(rolrod)
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(54 intermediate revisions by 33 users not shown)
Line 1: Line 1:
[http://surf4thesoul.com/classads/pictures/cats/picture/c4tgol.html grand] [http://www.dressuparcade.com/cjstats/cache/resacn.html similac] [http://scanpancookware.com/bmz_cache/9/pics/rochio.html wait whisper] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/letosarer.html s05 smallville] [http://lisameyer.com/mls_lite/icons/fic4td.html illinois senator] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/koc4ter.html loma linda] [http://emahofoundation.org/phpBB/images/avatars/pics/zarfevf.html oxford hills realty] [http://unconcealment.org/breview/wp-includes/js/quick/qasfok.html word art] [http://www.dressuparcade.com/cjstats/cache/golinpas.html what is my mac address xp] [http://www.dressuparcade.com/cjstats/cache/caroxre.html catherine bell measurements] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/acelelt.html wachovia car loan rates] [http://swissdiamondstore.com/bmz_cache/a/tmp_pics/neviqas.html empire sports network folds] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/bocnadomb.html jumpking trampoline] [http://jciti.com/jTalk/images/avatars/gallery/avatars/logeto.html emotional roots of disease] [http://surfpicsdaily.com/gallery/data/media/3/etqasco.html west virginia golden gloves] [http://wtssc.com/dgall/album/album2/photos/fucnabrd.html symptom of meningiomas] [http://scanpancookware.com/bmz_cache/9/pics/enlase.html nine black alps] [http://scanpancookware.com/bmz_cache/9/pics/index.html page] [http://webdesignassociates.net/DiscontinuedForum/Packages/files/botrnosa.html visible laser module] [http://www.kneep.nl/images/portfolio/Thumbs/domsedse.html bambie] [http://dsmc.info/gb/public/files/deernrcbo.html alc 880 driver] [http://jciti.com/jTalk/images/avatars/gallery/avatars/cadeza.html elephant man.com] [http://lisily.net/cutenews/data/upimages/pics/raclowb.html www casual corner com] [http://jciti.com/jTalk/images/avatars/gallery/avatars/basdel.html the force due to gravity] [http://teacherplacesexpertgroups.com/whelp/files/zeldelre.html asp encryption algorithm] [http://surf4thesoul.com/classads/pictures/cats/picture/getnodo.html most important computer components] [http://lisameyer.com/mls_lite/icons/zarbocac.html advanced carp fishing] [http://www.dressuparcade.com/cjstats/cache/bodomb.html free mature video] [http://unconcealment.org/breview/wp-includes/js/quick/elqasnotr.html india australia] [http://unconcealment.org/breview/wp-includes/js/quick/debrderel.html new hampshire airport] [http://emahofoundation.org/phpBB/images/avatars/pics/acelzell.html pokemon emerald] [http://www.dressuparcade.com/cjstats/cache/eltmex.html the spanish influenza] [http://unconcealment.org/breview/wp-includes/js/quick/fevcbos.html pictures of hands] [http://www.dressuparcade.com/cjstats/cache/rolzelcxd.html johne] [http://owencounty.org/forumx/OLD/images/xmbforum/pics/ouenacel.html equestriansingles.com] [http://teacherplacesexpertgroups.com/whelp/files/viquasedt.html manyways junction] [http://mybtdt.com/catalog/images/Thumbs/enfixc.html truck rims] [http://jamesurf.com/gallery/albums/userpics/10002/fuvarde.html audio cars] [http://floricane.com/guests/upload/preview/files/chiorc.html strathmore] [http://scanpancookware.com/bmz_cache/9/pics/zarcricbu.html ecampus] [http://swissdiamondstore.com/bmz_cache/a/tmp_pics/sitemap.html sitemap] [http://emahofoundation.org/phpBB/images/avatars/pics/trrica.html ecotourism] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/komonzarp.html wecam chats] [http://emahofoundation.org/phpBB/images/avatars/pics/refoko.html home search] [http://scanpancookware.com/bmz_cache/9/pics/cnaleto.html lotion for dry skin] [http://www.anef.org/telechargement/cache/sacsam.html new mobile homes] [http://floricane.com/guests/upload/preview/files/zolotroc.html prescription medicine] [http://surfpicsdaily.com/gallery/data/media/3/index.html web] [http://www.coffee-machines.com/articles/photoimages/Thumbs/letopasp.html hold em poker] [http://lisily.net/cutenews/data/upimages/pics/oloalc4t.html top old] [http://owencounty.org/forumx/OLD/images/xmbforum/pics/golnec.html idlewild park] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/acelbocnr.html catering supplies] [http://www.coffee-machines.com/articles/photoimages/Thumbs/rolacroc.html little prince boston opera] [http://westcornwallactivitycentre.com/coppermine/albums/userpics/10001/brfubas.html ascii value for a] [http://mybtdt.com/catalog/images/Thumbs/bocricqas.html raster logs] [http://mybtdt.com/catalog/images/Thumbs/nrelel.html luke air force base] [http://jciti.com/jTalk/images/avatars/gallery/avatars/eltzarq.html powers of the mind] [http://www.dressuparcade.com/cjstats/cache/cogetleto.html truth hurts addictive lyric] [http://mybtdt.com/catalog/images/Thumbs/wzelenace.html staircases design] [http://webdesignassociates.net/DiscontinuedForum/Packages/files/dronoralf.html www.optoutprescreen.com] [http://jamesurf.com/gallery/albums/userpics/10002/corack.html wager manchester] [http://www.dressuparcade.com/cjstats/cache/sitrodron.html fashion accessories] [http://wtssc.com/dgall/album/album2/photos/elricza.html t1 83 plus calculator] [http://floricane.com/guests/upload/preview/files/relbrboc.html free wallpaper downloads] [http://emahofoundation.org/phpBB/images/avatars/pics/fevviba.html bbs pedo] [http://lisameyer.com/mls_lite/icons/passedric.html stacey keibler] [http://mistergreens.com/recipes/docs/delsitxc.html dogpile email] [http://www.coffee-machines.com/articles/photoimages/Thumbs/zbokoa.html brooke richards video, brooke richards] [http://jciti.com/jTalk/images/avatars/gallery/avatars/domoubas.html evinrude spark plug] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/wetcoa.html china importer toy] [http://www.gamecaddy.com/games/files/tmp/monfokdev.html writing submissions] [http://surf4thesoul.com/classads/pictures/cats/picture/elerpl.html watergate newspaper article] [http://jamesurf.com/gallery/albums/userpics/10002/neorza.html plus size bridal bra] [http://jamesurf.com/gallery/albums/userpics/10002/chirac.html zotob virus] [http://www.dressuparcade.com/cjstats/cache/elxpasch.html solitaire diamonds] [http://www.coffee-machines.com/articles/photoimages/Thumbs/oucosa.html likely more] [http://swissdiamondstore.com/bmz_cache/a/tmp_pics/hensaze.html interial] [http://www.gamecaddy.com/games/files/tmp/cadomfit.html comfort measures during labor] [http://westcornwallactivitycentre.com/coppermine/albums/userpics/10001/varrenre.html gas power scooters] [http://mybtdt.com/catalog/images/Thumbs/pasplle.html rsd] [http://www.dressuparcade.com/cjstats/cache/bomonlo.html private jet tour] [http://emahofoundation.org/phpBB/images/avatars/pics/nrzarbasm.html pen drive] [http://surfpicsdaily.com/gallery/data/media/3/dronacro.html benton county jail] [http://floricane.com/guests/upload/preview/files/baseltc4t.html red bottoms] [http://sunraygrill.com/_messageboard/files/archive/images/dronbas.html israel phone directory] [http://teacherplacesexpertgroups.com/whelp/files/sazeln.html huge jugs] [http://mistergreens.com/recipes/docs/inmonf.html kittens ragdoll] [http://jamesurf.com/gallery/albums/userpics/10002/paslovars.html paint gun] [http://jciti.com/jTalk/images/avatars/gallery/avatars/zoloenroe.html picture of colonial child] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/fadelxdro.html canon 300d] [http://owencounty.org/forumx/OLD/images/xmbforum/pics/qasxzar.html frat boy jock] [http://webdesignassociates.net/DiscontinuedForum/Packages/files/domacf.html extractor health juice part waring] [http://mistergreens.com/recipes/docs/sitemap.html webmap] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/cocletoal.html motorola v170] [http://mistergreens.com/recipes/docs/virolreca.html washington county jail] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/wremexsit.html trucos msn] [http://dsmc.info/gb/public/files/zmexint.html machiavelli timeline] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/sadeta.html welcome home banners] [http://emahofoundation.org/phpBB/images/avatars/pics/dommon.html vegas video 5.0 review] [http://unconcealment.org/breview/wp-includes/js/quick/mexacel.html june summer photography] [http://www.coffee-machines.com/articles/photoimages/Thumbs/rolxc4tal.html asuka sawaguchi] [http://jciti.com/jTalk/images/avatars/gallery/avatars/losaded.html oppenheimer] [http://dsmc.info/gb/public/files/funoacer.html european american shoe size comparison] [http://surfpicsdaily.com/gallery/data/media/3/dedronro.html american symbols] [http://www.coffee-machines.com/articles/photoimages/Thumbs/trocin.html premployment screening] [http://www.dressuparcade.com/cjstats/cache/elfabo.html tig] [http://owencounty.org/forumx/OLD/images/xmbforum/pics/vipaszar.html senior pastor jobs] [http://wtssc.com/dgall/album/album2/photos/monc4to.html a kiss between the legs] [http://www.coffee-machines.com/articles/photoimages/Thumbs/relbas.html ag chemical prices] [http://www.gamecaddy.com/games/files/tmp/sazelcaa.html pf speaker systems] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/laxpasdel.html canada trust] [http://sunraygrill.com/_messageboard/files/archive/images/c4tlaac.html efax] [http://floricane.com/guests/upload/preview/files/nemonbasl.html mariah carey german tv] [http://mistergreens.com/recipes/docs/cazelf.html wedding day jewelers store] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/zargetfi.html seedtime and harvest] [http://www.anef.org/telechargement/cache/saerhe.html flooding] [http://scanpancookware.com/bmz_cache/9/pics/eracfuqa.html nine days] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/getsit.html underage lolita sex, lolita sex] [http://mybtdt.com/catalog/images/Thumbs/fokccna.html warlock] [http://www.coffee-machines.com/articles/photoimages/Thumbs/qasacelel.html cheap gas powered scooters] [http://westcornwallactivitycentre.com/coppermine/albums/userpics/10001/caeneltb.html amitriptyline] [http://mistergreens.com/recipes/docs/coactrra.html speak] [http://surf4thesoul.com/classads/pictures/cats/picture/sitemap.html links] [http://lisily.net/cutenews/data/upimages/pics/falotrfa.html nature valley sweet salty nut granola bar] [http://jamesurf.com/gallery/albums/userpics/10002/zarcaetn.html iron supplement] [http://www.coffee-machines.com/articles/photoimages/Thumbs/sedracb.html ohio state bird] [http://www.dressuparcade.com/cjstats/cache/rezelelt.html cute young boys gallery] [http://scanpancookware.com/bmz_cache/9/pics/rolnrf.html yves rocher] [http://webdesignassociates.net/DiscontinuedForum/Packages/files/wcaacdela.html westie scottie] [http://dsmc.info/gb/public/files/sedlolet.html tamagotchi web sites] [http://www.seedakota.com/psjs_datalogs/mailerdakota2003/data/history/bugc4tres.html bay area carpet cleaning service] [http://www.gamecaddy.com/games/files/tmp/zelnrr.html information on diet] [http://wtssc.com/dgall/album/album2/photos/rorelcfi.html saisaki restaurant] [http://www.coffee-machines.com/articles/photoimages/Thumbs/letomexsa.html joe paterno] [http://jciti.com/jTalk/images/avatars/gallery/avatars/zeleltad.html desert sun] [http://jamesurf.com/gallery/albums/userpics/10002/losage.html national racing museum] [http://surfpicsdaily.com/gallery/data/media/3/pasroz.html mediashopping] [http://jciti.com/jTalk/images/avatars/gallery/avatars/finrmon.html unix support] [http://emahofoundation.org/phpBB/images/avatars/pics/caviqasq.html first time home mortgages california] [http://www.coffee-machines.com/articles/photoimages/Thumbs/letobor.html tapes industrial] [http://www.dressuparcade.com/cjstats/cache/oufuxfe.html home loans refinance] [http://www.anef.org/telechargement/cache/fevelta.html rode runner] [http://www.coffee-machines.com/articles/photoimages/Thumbs/dombugfo.html ungulate mammal] [http://jciti.com/jTalk/images/avatars/gallery/avatars/alsitric.html electric sunglasses] [http://wtssc.com/dgall/album/album2/photos/bocsad.html erotic first time sex story] [http://mistergreens.com/recipes/docs/vifidare.html antique bulova watches] [http://wtssc.com/dgall/album/album2/photos/delmone.html flirting tips for girls] [http://surfpicsdaily.com/gallery/data/media/3/orolobral.html effects of alcohol] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/wrobugnr.html envelope sizes] [http://lisameyer.com/mls_lite/icons/safufif.html new zealand history] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/nofakoo.html the sun newspaper] [http://westcornwallactivitycentre.com/coppermine/albums/userpics/10001/coetc4tch.html the doors riders on the storm] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/racalne.html pokoemon] [http://www.coffee-machines.com/articles/photoimages/Thumbs/nezeldarh.html sarah fullerton] [http://swissdiamondstore.com/bmz_cache/a/tmp_pics/wletochir.html waterproof nontoxic cosmetic foundations] [http://sunraygrill.com/_messageboard/files/archive/images/index.html webmap] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/endedo.html miller lite promotions] [http://surfpicsdaily.com/gallery/data/media/3/getviko.html coolnavi.com] [http://mistergreens.com/recipes/docs/derosarel.html foreign language] [http://www.gamecaddy.com/games/files/tmp/golelnoet.html vonage song] [http://lisily.net/cutenews/data/upimages/pics/index.html home] [http://lisameyer.com/mls_lite/icons/sitelt.html wholesale gift baskets] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/index.html sitemap] [http://lisameyer.com/mls_lite/icons/accoout.html ohio amish] [http://sunraygrill.com/_messageboard/files/archive/images/nerolenla.html tia and tamera mowry] [http://wtssc.com/dgall/album/album2/photos/aldombrg.html 13 year old teen pics] [http://www.kneep.nl/images/portfolio/Thumbs/loeltr.html shop fox band saw] [http://wtssc.com/dgall/album/album2/photos/chicasedn.html el paso county] [http://swissdiamondstore.com/bmz_cache/a/tmp_pics/trfalitrp.html restorative techniques] [http://sennensurfingcentre.com/gallery2/g2data/locks/0/11/brclinein.html rent an rv canada] [http://www.gamecaddy.com/games/files/tmp/rolacr.html airline yield definition] [http://jamesurf.com/gallery/albums/userpics/10002/boricdelm.html maybelline new york cosmetics] [http://jamesurf.com/gallery/albums/userpics/10002/acfokzarc.html home based business marketing] [http://www.dressuparcade.com/cjstats/cache/tatroccab.html long beach business travel] [http://www.gamecaddy.com/games/files/tmp/ettazf.html steelers will win the super bowl] [http://mistergreens.com/recipes/docs/bocacdara.html amateur teen model] [http://www.gamecaddy.com/games/files/tmp/sitemap.html sitemap] [http://www.dressuparcade.com/cjstats/cache/allowfe.html aol broadband] [http://westcornwallactivitycentre.com/coppermine/albums/userpics/10001/fafucap.html tax debt] [http://www.seedakota.com/psjs_datalogs/mailerdakota2003/data/history/sitloget.html invoice factoring company] [http://surfpicsdaily.com/gallery/data/media/3/index.html web] [http://jciti.com/jTalk/images/avatars/gallery/avatars/brvarnrn.html beyonce booty] [http://surf4thesoul.com/classads/pictures/cats/picture/index.html page] [http://www.kneep.nl/images/portfolio/Thumbs/koerpas.html janet jones] [http://kosherwinesociety.com/editortest1/UploadImages/Thumbs/index.html url] [http://www.gamecaddy.com/games/files/tmp/nrvarrel.html mini lathes] [http://lisameyer.com/mls_lite/icons/inc4tcai.html married woman who cheat] [http://www.coffee-machines.com/articles/photoimages/Thumbs/olosedrol.html nevada cathouses] [http://lisameyer.com/mls_lite/icons/wdronca.html rapala] [http://dsmc.info/gb/public/files/plsada.html cheap flights uk] [http://www.dressuparcade.com/cjstats/cache/favara.html streamwood restaurants] [http://mistergreens.com/recipes/docs/letoerra.html police auction] [http://mistergreens.com/recipes/docs/dezactr.html online home school] [http://jamesurf.com/gallery/albums/userpics/10002/fevnrri.html beautiful cross dressers] [http://westcornwallactivitycentre.com/coppermine/albums/userpics/10001/cadomloa.html import cars wallpaper] [http://owencounty.org/forumx/OLD/images/xmbforum/pics/xcxrol.html gerard way pictures] [http://www.seedakota.com/psjs_datalogs/mailerdakota2003/data/history/domvarfe.html 6 day 7 nights] [http://surf4thesoul.com/classads/pictures/cats/picture/xreboc.html gold] [http://mistergreens.com/recipes/docs/wtrcwvarc.html derek jeter] [http://sunraygrill.com/_messageboard/files/archive/images/breltincn.html maria callas]
{{LanguageBar}}
 
A '''pre'''made '''fab'''rication, or '''prefab''', is a separately saved object, usually consisting of multiple parts - 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.
A '''pre'''made '''fab'''rication, or '''prefab''', is a separately saved object, usually consisting of multiple parts - 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 files (.[[VMF]]) that contain only your prefab. These files are stored in a particular prefab folder, generally <code>\sourcesdk\bin\prefabs</code>, so that [[Valve Hammer Editor|Hammer]] can find them and allow you to easily insert them into your levels.
Prefabs are simply small map files (.[[VMF]]) that contain only your prefab. These files are stored in a particular prefab folder, generally {{path|\sourcesdk\bin\prefabs}}, so that [[Valve Hammer Editor|Hammer]] can find them and allow you to easily insert them into your levels.
 
'''Note:''' For orangebox games, make sure to use the {{path|\sourcesdk\bin\orangebox\bin\prefabs}}. For additional guidance on the location of built-in Source SDK prefabs, see [[:Category:Prefabs]].


Prefabs can be organized into their own hierarchy by simply adding sub-folders to the <code>\prefabs</code>  directory. This allows you to sort prefabs based on, amongst others, the intended map or mod they belong to, thus possibly easing their navigation.
Prefabs can be organized into their hierarchy by simply adding sub-folders to the <code>\prefabs</code>  directory. This allows you to sort prefabs based on, amongst others, the intended map or mod they belong to, thus possibly easing their navigation.


== Creating prefabs ==
== Creating prefabs ==
Prefabs can be created in the Hammer editor with these steps:
Prefabs can be created in the Hammer editor with these steps:
# If this prefab is intended to interact with named objects inside itself, add the "_&i" token at the end of each object's name. See [[#Prefab tokens|Prefab tokens]] below.
# If this prefab is intended to interact with named objects inside itself, add the "_&i" token at the end of each object's name. See [[#Prefab tokens|Prefab tokens]] below.
# Select the objects you wish to include in your prefab (using <Ctrl>-click).
# Select the objects you wish to include in your prefab (using {{key|Ctrl|MOUSE1}}).
# 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|Object bar]], or select the '''Create Prefab''' command from the [[Hammer_Tools_Menu|Tools menu]]. (Shortcut key: {{key|Ctrl+R}})
# 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. {{note|While the ''.vmf'' extension should be automatically added to the filename, some users have experienced this not being the case. To be on the safe side, add ''.vmf'' to the filename to ensure that the prefab will show up. You can also add it later by browsing to the prefabs folder.}}
# 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. {{note|While the ''.vmf'' extension should be automatically added to the filename, some users have experienced this not being the case. To be on the safe side, add ''.vmf'' to the filename to ensure that the prefab will show up. You can also add it later by browsing to the prefabs folder.}} {{bug|hidetested=1|After saving the very first prefab, Hammer might crash.}}
# The new prefab will now be available for insertion in the '''New Objects''' toolbar.
# The new prefab will now be available for insertion in the [[Hammer New Objects Toolbar|Object bar]].


=== Prefab tokens ===
=== Prefab tokens ===
A special ''token'' "&i" can be added to the name of entities in prefab objects so the entity will have a unique name when placed in the level. When the prefab is placed, the &i token will be replaced by a unique number. The token can be included in the [[targetname]], [[Inputs and Outputs|inputs and outputs]], etc. All tokens in the prefab will be replaced with the same number. This allows entities in the prefab to reference each other, but still have a unique name so multiple prefabs won't trigger each other.
A special ''token'' "&i" can be added to the name of entities in prefab objects so the entity will have a unique name when placed in the level. When the prefab is placed, the &i token will be replaced by a unique number. The token can be included in the [[targetname]], [[Inputs and Outputs|inputs and outputs]], etc. All tokens in the prefab will be replaced with the same number. This allows entities within the prefab to reference each other, but still have a unique name so multiple prefabs won't trigger each other.


For example, a [[func_door]] entity with the name "door_sliding_&i" in the prefab would become "door_sliding_1" when placed in a level. Consecutive placements of the prefab would be called "door_sliding_2", "door_sliding_3", ...
For example, a [[func_door]] entity with the name "door_sliding_&i" in the prefab would become "door_sliding_1" when placed in a level. Consecutive placements of the prefab would be called "door_sliding_2", "door_sliding_3", ...


A [[trigger_multiple]] included ''in the same prefab'', with the name "trigger_sliding_&i", would share the same token number and be renamed "trigger_sliding_1", "trigger_sliding_2", "trigger_sliding_3", ...
A [[trigger_multiple]] included ''in the same prefab'', set to trigger "door_sliding_&i" upon initial creation, would upon insertion share the same token number as the door.
 
{{note|Other values, like specific ''Brush faces'' attached to prefab [[env_cubemap]]s, cannot be saved, and have to be reset upon each insertion.}}
{{note|The parameter field of outputs is NOT affected. {{note|Is affected sometimes? Maybe {{h++}} }} }}
 
For ways to address prefab names using this token, see [[Inputs_and_Outputs|search wildcards]].
 
{{tip|Using an asterisk (*) in your searches filters prefabs using a wildcard. For example, searching ''door_*'' would return ''door_1'', ''door_2'', ''door_red_7'', etc.}}
 
{{bug|hidetested=1|"_&i" does not work for node hint groups.}}
{{bug|hidetested=1|"_&i" does not work for non-existent entities. For example, you can't have parent for an entity, if parent isn't in prefab, because "_&i" will not change in <code>Parent</code> property. The same will happen with outputs.}}
 
=== Prefab containers ===
In Valve Hammer Editor up to Version 3.5 prefabs can be stored in [[OL|.ol]] files. This File Format acts as a container and can store several [[.map]] and [[.rmf]] prefabs in it. With the ''Prefab Factory'' Menu in Hammer Editor it is possible to add or remove Objects to the Libary.


== Inserting prefabs ==
== Inserting prefabs ==
[[Image:hammer_newobjects.jpg|right]]
[[File:hammer_newobjects.jpg|right]]


Once you have prefab objects created, it is a simple task to insert a prefab into your level.
Once you have prefab objects created, it is a simple task to insert a prefab into your level.


There are two ways of putting a prefab into your level: Using the [[Hammer Entity Tool|Entity Tool]], or using the [[Hammer Block Tool|Block Tool]].
There are two ways of putting a prefab into your level: Using the {{Hammer entity}}, or using the {{Hammer block}}.


The process is basically the same for both tools: First select the tool you wish to use, then select the prefab from the [[Hammer New Objects Toolbar|New Objects toolbar]], and then insert it through one of the views.
The process is basically the same for both tools: First select the tool you wish to use, then select the prefab from the [[Hammer New Objects Toolbar|Object bar]], and then insert it through one of the views.


The '''Entity Tool''' should be used for most prefab placement, as it retains the exact size of the original prefab. Placement with the '''Block Tool''' allows for resizing of the prefab as it's placed, but is slightly more time-consuming to place correctly.
The {{Hammer entity}} should be used for most prefab placement, as it retains the exact size of the original prefab. Placement with the {{Hammer block}} allows for resizing of the prefab as it's placed, but is slightly more time-consuming to place correctly.


{{tip|After choosing one of the prefab creation tools (either the Entity Tool or the Block Tool), then selecting a prefab library, picking the same creation tool a second time will enable the '''Insert original prefab''' button in the New Objects toolbar. You can use this button to insert the selected prefab in the center of the 2D views. After placing the prefab, it can be moved into place. Make sure [[Hammer_Map_Operations_Toolbar|Texture Locking]] is turned on!}}{{clr}}
{{tip|After choosing one of the prefab creation tools (either the Entity Tool or the Block Tool), then selecting a prefab library, picking the same creation tool a second time will enable the '''Insert original prefab''' button in the Object bar. You can use this button to insert the selected prefab in the center of the 2D views. After placing the prefab, it can be moved into place. Make sure [[Hammer_Map_Operations_Toolbar|Texture Locking]] is turned on!}}{{clr}}


=== Using the Entity Tool ===
=== Using the Entity Tool ===
[[Image:Mt-entities.png]] The '''Entity Tool''' is used to place a prefab object that should retain its original size.
[[File:InsertPrefabTut1.png|right|200px]]
[[File:InsertPrefabTut2.png|right|200px]]
[[File:InsertPrefabTut3.png|right|200px]]
 
The {{Hammer entity}} is used to place a prefab object that should retain its original size.


# Select the '''Entity Tool''' from the toolbar or by pressing <Shift+E>.
# Select the {{Hammer entity}} from the toolbar. (Shortcut: {{key|Shift+E}})
# In the [[Hammer New Objects Toolbar|New Objects]] toolbar, select a prefab library in the '''Categories:''' selection box.
# In the [[Hammer New Objects Toolbar|Object bar]], select a prefab library in the '''Categories:''' selection box.
# Select a specific prefab to insert from the library in the '''Objects:''' selection box.
# Select a specific prefab to insert from the library in the '''Objects:''' selection box.
# Click in the '''3D view''' where you want the prefab to be placed, or click in one of the '''2D views''' and press <Enter> to insert the prefab.
# Click in one of the 2D views where you want the prefab to be placed. Alternatively you can instead just click in the 3D view, whereupon the prefab will be inserted automatically.
# Press {{key|Return}} or {{key|Enter}} to insert the prefab.


=== Using the Block Tool ===
=== Using the Block Tool ===
[[Image:Mt-block.png]] The '''Block Tool''' is used if you want to insert a prefab scaled to a certain size.
The {{Hammer block}} is used if you want to insert a prefab scaled to a certain size.
[[Image:InsertSizedPrefab.png|right]]


To place a prefab object, scaling it to an exact size:
To place a prefab object, scaling it to an exact size:
# Select the '''Block Tool''' from the toolbar or by pressing <Shift+B>.
# Select the {{Hammer block}} from the toolbar. (Shortcut: {{key|Shift+B}})
# In the [[Hammer New Objects Toolbar|New Objects]] toolbar, select a prefab library in the '''Categories:''' selection box. Then select a specific prefab to insert from the library in the '''Objects:''' selection box.
# In the [[Hammer New Objects Toolbar|Object bar]], select a prefab library in the '''Categories:''' selection box.
# Select a specific prefab to insert from the library in the '''Objects:''' selection box.
# Drag a selection box in one of the 2D views, making sure it is the size and in the position that you want the prefab to be in each of the views.
# Drag a selection box in one of the 2D views, making sure it is the size and in the position that you want the prefab to be in each of the views.
# Press <Enter>. The prefab will inserted, and scaled to fit the selection box.{{clr}}
# Press {{key|Return}} or {{key|Enter}} to insert the prefab. It will be scaled to fit the selection box.
{{clr}}
 
Notice that any inserted prefab is automatically [[group|grouped]], and therefore the Objects selection mode must be used to move individual objects and access their entity properties.
 
== The Skip tool texture ==
 
A prefab typically consists of many objects that you want to move or copy somewhere, and if the prefab happens to be of an odd size, you may end up with components ending up not exactly where you want them. You can prevent this by enveloping the prefab inside a [[skip]] [[tool texture]]:
 
# Set the grid size to a the maximum size that you expect to move the prefab in. (Typically you plan the [[skip]] brush to be a size of about 4x4x4 grid squares.)
# Create a brush enveloping all the components of the prefab. It's best to select all objects beforehand, because you'll see all the affected volume, since some models may have large bounding boxes. If those are not fully encased, the entire thing may not align on the grid.
# Cover every side of the brush with the [[skip]] [[tool texture]].
# Select all the components of the prefab (''including'' the [[skip]] brush) and save it.
 
The positions of the components inside the brush are now relative to the enveloping [[skip]] brush, and the even size of the brush makes the movements of every component on par with the Hammer editor's graph. As the brush is covered in a [[skip]] [[tool texture]], it will not be compiled with the map.


== Available prefabs ==
== See also ==
For a list of available prefabs in the Source SDK, see [[:Category:Prefabs]].
* [[:Category:Prefabs]] - a list of prefabs that are already available in the Source SDK
* [[func_instance]] - An advanced dynamic alternative to prefabs.


== External links ==
== External links ==
The following sites host custom made prefabs and models:
The following sites host custom made prefabs and models:


* [http://www.snarkpit.net/editing.php?page=files&game=HL2&type=prefabs&subcat=examples SnarkPit prefab database]
* [http://halflife2.filefront.com/files/Half-Life_2/Prefabs;2654 (HL2) File Front prefab database]
* [http://halflife2.filefront.com/files/Half-Life_2/Prefabs;2654 File Front prefab database]
* [http://gamebanana.com/prefabs/games/2 (CS:S) GAMEBANANA prefab database]
* [http://www.fpsbanana.com/prefabs/games/2 FPSBANANA prefab database]


[[Category:Hammer]]
[[Category:Hammer]]
[[Category:Level Design]]
[[Category:Level Design]]
[[Category:Glossary]]

Latest revision as of 07:07, 20 May 2025

English (en)Русский (ru)中文 (zh)Translate (Translate)

A premade fabrication, or prefab, is a separately saved object, usually consisting of multiple parts - 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 files (.VMF) 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.

Note: For orangebox games, make sure to use the 🖿\sourcesdk\bin\orangebox\bin\prefabs. For additional guidance on the location of built-in Source SDK prefabs, see Category:Prefabs.

Prefabs can be organized into their hierarchy by simply adding sub-folders to the \prefabs directory. This allows you to sort prefabs based on, amongst others, the intended map or mod they belong to, thus possibly easing their navigation.

Creating prefabs

Prefabs can be created in the Hammer editor with these steps:

  1. If this prefab is intended to interact with named objects inside itself, add the "_&i" token at the end of each object's name. See Prefab tokens below.
  2. Select the objects you wish to include in your prefab (using Ctrl+LMB).
  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 Object bar, 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.
    Note.pngNote:While the .vmf extension should be automatically added to the filename, some users have experienced this not being the case. To be on the safe side, add .vmf to the filename to ensure that the prefab will show up. You can also add it later by browsing to the prefabs folder.
    Icon-Bug.pngBug:After saving the very first prefab, Hammer might crash.
  6. The new prefab will now be available for insertion in the Object bar.

Prefab tokens

A special token "&i" can be added to the name of entities in prefab objects so the entity will have a unique name when placed in the level. When the prefab is placed, the &i token will be replaced by a unique number. The token can be included in the targetname, inputs and outputs, etc. All tokens in the prefab will be replaced with the same number. This allows entities within the prefab to reference each other, but still have a unique name so multiple prefabs won't trigger each other.

For example, a func_door entity with the name "door_sliding_&i" in the prefab would become "door_sliding_1" when placed in a level. Consecutive placements of the prefab would be called "door_sliding_2", "door_sliding_3", ...

A trigger_multiple included in the same prefab, set to trigger "door_sliding_&i" upon initial creation, would upon insertion share the same token number as the door.

Note.pngNote:Other values, like specific Brush faces attached to prefab env_cubemaps, cannot be saved, and have to be reset upon each insertion.
Note.pngNote:The parameter field of outputs is NOT affected.
Note.pngNote:Is affected sometimes? Maybe Hammer++

For ways to address prefab names using this token, see search wildcards.

Tip.pngTip:Using an asterisk (*) in your searches filters prefabs using a wildcard. For example, searching door_* would return door_1, door_2, door_red_7, etc.
Icon-Bug.pngBug:"_&i" does not work for node hint groups.
Icon-Bug.pngBug:"_&i" does not work for non-existent entities. For example, you can't have parent for an entity, if parent isn't in prefab, because "_&i" will not change in Parent property. The same will happen with outputs.

Prefab containers

In Valve Hammer Editor up to Version 3.5 prefabs can be stored in .ol files. This File Format acts as a container and can store several .map and .rmf prefabs in it. With the Prefab Factory Menu in Hammer Editor it is possible to add or remove Objects to the Libary.

Inserting prefabs

Hammer newobjects.jpg

Once you have prefab objects created, it is a simple task to insert a prefab into your level.

There are two ways of putting a prefab into your level: Using the Entity tool Mt-entities.png, or using the Block tool Hammer block.png.

The process is basically the same for both tools: First select the tool you wish to use, then select the prefab from the Object bar, and then insert it through one of the views.

The Entity tool Mt-entities.png should be used for most prefab placement, as it retains the exact size of the original prefab. Placement with the Block tool Hammer block.png allows for resizing of the prefab as it's placed, but is slightly more time-consuming to place correctly.

Tip.pngTip:After choosing one of the prefab creation tools (either the Entity Tool or the Block Tool), then selecting a prefab library, picking the same creation tool a second time will enable the Insert original prefab button in the Object bar. You can use this button to insert the selected prefab in the center of the 2D views. After placing the prefab, it can be moved into place. Make sure Texture Locking is turned on!

Using the Entity Tool

InsertPrefabTut1.png
InsertPrefabTut2.png
InsertPrefabTut3.png

The Entity tool Mt-entities.png is used to place a prefab object that should retain its original size.

  1. Select the Entity tool Mt-entities.png from the toolbar. (Shortcut: Shift+E)
  2. In the Object bar, select a prefab library in the Categories: selection box.
  3. Select a specific prefab to insert from the library in the Objects: selection box.
  4. Click in one of the 2D views where you want the prefab to be placed. Alternatively you can instead just click in the 3D view, whereupon the prefab will be inserted automatically.
  5. Press Return or Enter to insert the prefab.

Using the Block Tool

The Block tool Hammer block.png is used if you want to insert a prefab scaled to a certain size.

To place a prefab object, scaling it to an exact size:

  1. Select the Block tool Hammer block.png from the toolbar. (Shortcut: Shift+B)
  2. In the Object bar, select a prefab library in the Categories: selection box.
  3. Select a specific prefab to insert from the library in the Objects: selection box.
  4. Drag a selection box in one of the 2D views, making sure it is the size and in the position that you want the prefab to be in each of the views.
  5. Press Return or Enter to insert the prefab. It will be scaled to fit the selection box.

Notice that any inserted prefab is automatically grouped, and therefore the Objects selection mode must be used to move individual objects and access their entity properties.

The Skip tool texture

A prefab typically consists of many objects that you want to move or copy somewhere, and if the prefab happens to be of an odd size, you may end up with components ending up not exactly where you want them. You can prevent this by enveloping the prefab inside a skip tool texture:

  1. Set the grid size to a the maximum size that you expect to move the prefab in. (Typically you plan the skip brush to be a size of about 4x4x4 grid squares.)
  2. Create a brush enveloping all the components of the prefab. It's best to select all objects beforehand, because you'll see all the affected volume, since some models may have large bounding boxes. If those are not fully encased, the entire thing may not align on the grid.
  3. Cover every side of the brush with the skip tool texture.
  4. Select all the components of the prefab (including the skip brush) and save it.

The positions of the components inside the brush are now relative to the enveloping skip brush, and the even size of the brush makes the movements of every component on par with the Hammer editor's graph. As the brush is covered in a skip tool texture, it will not be compiled with the map.

See also

External links

The following sites host custom made prefabs and models: