Prefab: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (delgetta)
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(56 intermediate revisions by 35 users not shown)
Line 1: Line 1:
[http://historicmatewanhouse.com/guestbook/upload/preview/pics/fiqasxac.html used furniture] [http://bubs-bibs-n-burps.com/oscommerce/includes/languages/english/images/pics/denrta.html trawler for sale] [http://www.jeanwise.org/tmp/views_c/cache/caletoca.html apricot juice concentrate] [http://peopleit.net/store/admin/images/logo/thumbs/getquahe.html photos] [http://www.booknestguides.com/fishysearch/images/flags/thumbs/quaetd.html internet access monitoring and filtering] [http://www.rides4u.com/images/rides/thumbs/faordelr.html 1987 cadillac deville repair] [http://www.davidgrover.com/gallery/albums/July12/golc4td.html cadillac parts] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/mexmexcel.html rachel luttrell] [http://www.uppercanadaplayhouse.com/ssp_director/albums/album-2/en/ackonrdro.html new hampshire] [http://www.smartfindsmarketing.com/blog/wp-content/uploads/avatars/bugdelnel.html vipsports.com] [http://bubs-bibs-n-burps.com/oscommerce/includes/languages/english/images/pics/quaboct.html wiki documentation] [http://www.knifeshq.com/board/images/ercaquafo.html online coffee store] [http://www.thenetstudyguide.com/blog/wp-content/uploads/images/chitrca.html i scream you scream] [http://autographshop.com.au/category/uploadedfiles/thumbs/colobugf.html hot naked woman] [http://oyido.net/blog/wp-content/uploads/2007/03/bobocd.html cleavage and teens] [http://justgemsofsa.net/skin_cache/cacheid_1/passedac.html chrysler 300c srt8] [http://wiicentral.net/orders/images/images/golhensit.html hard male body gallery] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/codomf.html solid gold dog food free shipping] [http://blackacres.net/forum/images/avatars/gallery/pics/linekom.html lace scarf spanish women] [http://autographshop.com.au/category/uploadedfiles/thumbs/c4tfokli.html yamaha four wheelers] [http://www.knifeshq.com/board/images/furicd.html new jersey campgrounds] [http://www.sturmgrenadier.com/invision/skin_cache/cacheid_5/nrcanr.html condom game] [http://www.uppercanadaplayhouse.com/ssp_director/albums/album-2/en/index.html home] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/dronboza.html pussy pump] [http://www.uppercanadaplayhouse.com/ssp_director/albums/album-2/en/trocquaw.html tuxedo rental] [http://www.abto.org.bt/old_abto/images/fupasxfok.html s club] [http://www.holisticvitamins.com/shop/images/large/dvd/thumbs/boccnaen.html internet credit card processings] [http://www.jeanwise.org/tmp/views_c/cache/cnacafax.html real estates adelaide] [http://www.jasonmichaelbrown.com/search-engine-marketing/images/lanore.html muslum gurses usta lyrics] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/sitemap.html sitemap] [http://wiicentral.net/orders/images/images/sedrolf.html pirate 4x4] [http://www.abto.org.bt/old_abto/images/larollivi.html domymom] [http://www.rides4u.com/images/rides/thumbs/cnapasr.html long ninja shirt sleeve turtle] [http://daintreehermitcrabs.com/home/conf/profiles/files/trbocace.html african different instrument] [http://justgemsofsa.net/skin_cache/cacheid_1/rolelget.html sex doll] [http://www.abto.org.bt/old_abto/images/zcnasa.html cruise line jobs] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/daroule.html talking on the fone] [http://www.davidgrover.com/gallery/albums/July12/rowlodomr.html real estate santa cruz county] [http://ka-lan.com/gallery/albums/userpics/10002/letobasdr.html free lookup number phone reverse] [http://peopleit.net/store/admin/images/logo/thumbs/zarfufe.html clothing wholesale los angeles] [http://autographshop.com.au/category/uploadedfiles/thumbs/nrdoml.html prescription drugs] [http://www.rides4u.com/images/rides/thumbs/relwle.html neopets faerie quest] [http://www.booknestguides.com/fishysearch/images/flags/thumbs/etvarboal.html standards and specifications for concrete pipes of txdot] [http://www.1800topsoil.com/blog/wp-content/uploads/images/viquare.html wacky web tales] [http://www.holisticvitamins.com/shop/images/large/dvd/thumbs/basricf.html probiscus monkey picture] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/tralsitn.html calottery] [http://peopleit.net/store/admin/images/logo/thumbs/quaenl.html wedding gown] [http://www.fineartpost.com/gallery/albums/album03/orgolli.html solve transshipment schedule] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/pascar.html amateur movie] [http://bubs-bibs-n-burps.com/oscommerce/includes/languages/english/images/pics/elriclon.html the end] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/qasetb.html providian] [http://yellowshoe.com.au/tips/wp-content/themes/yellowshoe/picture/relvireen.html insurance] [http://www.davidgrover.com/gallery/albums/July12/getalal.html wholesale table lamp] [http://www.jasonmichaelbrown.com/search-engine-marketing/images/tafoksed.html eddie van halen] [http://justgemsofsa.net/skin_cache/cacheid_1/cnacovi.html blackdicks] [http://justgemsofsa.net/skin_cache/cacheid_1/corezarli.html add minutes to tracfone] [http://www.abto.org.bt/old_abto/images/cocazelra.html parenting advice] [http://oyido.net/blog/wp-content/uploads/2007/03/pasquawp.html nude rap uncut video] [http://www.thenetstudyguide.com/blog/wp-content/uploads/images/cavarrere.html attorney idaho insurance] [http://www.trpservices.com/userfiles/image/001/nogetnrn.html girl power] [http://www.1800topsoil.com/blog/wp-content/uploads/images/pasplfok.html gourds] [http://www.sturmgrenadier.com/invision/skin_cache/cacheid_5/decaeltbr.html russian mom] [http://www.1800topsoil.com/blog/wp-content/uploads/images/ricerou.html arora] [http://www.squadwerks.com/knowledge_base/admin/images/thumbs/mexzquale.html safety relief valves] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/kofawmo.html quotes on love] [http://www.jasonmichaelbrown.com/search-engine-marketing/images/fuloetric.html hytrin] [http://yellowshoe.com.au/tips/wp-content/themes/yellowshoe/picture/darqass.html share prices] [http://longlifelighting.com.au/news/wp-content/uploads/images/lolachie.html indian bride] [http://www.abto.org.bt/old_abto/images/rezaro.html industrial scales] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/inliorb.html complications gastric bypass] [http://justgemsofsa.net/skin_cache/cacheid_1/etc4tnog.html gevalia coffee] [http://oyido.net/blog/wp-content/uploads/2007/03/sitemap.html http] [http://ka-lan.com/gallery/albums/userpics/10002/henplsi.html chess end games] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/oloetza.html map of eastern europe] [http://marketingop.us/wp-content/uploads/2006/07/aceltafib.html cheap headwear] [http://www.usedhomeschoolcurriculum.com/Themes/default/fonts/Candice/gif/reeltmex.html toyota celica door] [http://www.trpservices.com/userfiles/image/001/monaci.html white mountain region pony club] [http://www.sghq.com/catalog/images/banners/new/bugkotro.html solaronics inc.] [http://marketingop.us/wp-content/uploads/2006/07/canequ.html ejb ql in operator] [http://bubs-bibs-n-burps.com/oscommerce/includes/languages/english/images/pics/tamexo.html hcmf joiner] [http://marketingop.us/wp-content/uploads/2006/07/endebaspa.html team building ideas] [http://www.rides4u.com/images/rides/thumbs/fevinca.html nextell] [http://501qld.com/forum/includes/sql/dump/wnrfaloz.html log scaling] [http://www.abto.org.bt/old_abto/images/golpas.html low temp freezer] [http://daintreehermitcrabs.com/home/conf/profiles/files/nrfamon.html american zoetrope virtual studio] [http://www.libertytitlecorp.com/templates_c/150/racinm.html vancouver canada] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/alzarbasd.html anal orgasm] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/ercage.html napoleonic toy soldiers] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/lolinr.html motorola fax modem] [http://www.knifeshq.com/board/images/mexlich.html lifeguarding equipment] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/enzelr.html dvd downloads] [http://www.booknestguides.com/fishysearch/images/flags/thumbs/nrrelcoq.html photo by carl] [http://ka-lan.com/gallery/albums/userpics/10002/sitemap.html map] [http://www.knifeshq.com/board/images/brquadarc.html saddle rack] [http://www.jasonmichaelbrown.com/search-engine-marketing/images/relvarbo.html importance of organizations behaving ethically] [http://www.jasonmichaelbrown.com/search-engine-marketing/images/darnecztr.html lady marmalade video] [http://justgemsofsa.net/skin_cache/cacheid_1/acnrerfaa.html cosmetics] [http://www.sghq.com/catalog/images/banners/new/monbrenca.html bangkok special girls] [http://justgemsofsa.net/skin_cache/cacheid_1/goldelib.html home interior] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/dezcna.html ephedra diet pill] [http://justgemsofsa.net/skin_cache/cacheid_1/wlisith.html interior design schools] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/hensapasl.html maine] [http://longlifelighting.com.au/news/wp-content/uploads/images/elelvif.html list of baby girls names] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/deinfan.html hub caps] [http://peopleit.net/store/admin/images/logo/thumbs/resedz.html classic chevrolet] [http://www.usedhomeschoolcurriculum.com/Themes/default/fonts/Candice/gif/bocqasne.html limo reading pa] [http://www.holisticvitamins.com/shop/images/large/dvd/thumbs/lolanrf.html seroquel and side effect] [http://blackacres.net/forum/images/avatars/gallery/pics/inbugko.html neu] [http://daintreehermitcrabs.com/home/conf/profiles/files/loletosac.html argument from design] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/plcvides.html real estate kauai] [http://www.sturmgrenadier.com/invision/skin_cache/cacheid_5/domrol.html advance healthcare group ltd] [http://www.rides4u.com/images/rides/thumbs/fibotahen.html renegade] [http://www.uppercanadaplayhouse.com/ssp_director/albums/album-2/en/bocdar.html pictures of cows with mad cow disease] [http://bubs-bibs-n-burps.com/oscommerce/includes/languages/english/images/pics/bascao.html linkin park lyrics] [http://www.knifeshq.com/board/images/viaczel.html shedaisy] [http://www.booknestguides.com/fishysearch/images/flags/thumbs/roboda.html family jewels] [http://www.rides4u.com/images/rides/thumbs/entrgolv.html 5 s] [http://www.apxuf.org/e107_docs/help/English/Files/nopaso.html marines iraq killed] [http://daintreehermitcrabs.com/home/conf/profiles/files/zarinfi.html anticellulite creams] [http://www.apxuf.org/e107_docs/help/English/Files/getrac.html dui lawyer] [http://longlifelighting.com.au/news/wp-content/uploads/images/darbofok.html innotek] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/monacel.html oriental dragons] [http://www.apxuf.org/e107_docs/help/English/Files/boelro.html palm pilot battery replace] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/oreltge.html wilson cruz rent] [http://www.thenetstudyguide.com/blog/wp-content/uploads/images/xletono.html d-cup] [http://marketingop.us/wp-content/uploads/2006/07/neinace.html picture slate roof] [http://www.sturmgrenadier.com/invision/skin_cache/cacheid_5/nefure.html girlamatic] [http://www.latestdiscountvouchers.co.uk/rss/sitemap/zelqua.html this is the story of my life] [http://www.1800topsoil.com/blog/wp-content/uploads/images/debohenr.html used restaurant equipment phoenix] [http://www.holisticvitamins.com/shop/images/large/dvd/thumbs/fuchisaer.html euro 2004 free kick challenge] [http://www.booknestguides.com/fishysearch/images/flags/thumbs/licozelze.html bluechart] [http://bubs-bibs-n-burps.com/oscommerce/includes/languages/english/images/pics/bracelcva.html sachets brazil] [http://justgemsofsa.net/skin_cache/cacheid_1/delcainm.html orgasm sounds] [http://justgemsofsa.net/skin_cache/cacheid_1/quabocp.html anal sex with my wife] [http://blackacres.net/forum/images/avatars/gallery/pics/bugmex.html artist chicago photographer] [http://www.usedhomeschoolcurriculum.com/Themes/default/fonts/Candice/gif/liacnoro.html discount scuba] [http://www.rides4u.com/images/rides/thumbs/sitreb.html big tymers still fly] [http://www.usedhomeschoolcurriculum.com/Themes/default/fonts/Candice/gif/zelzzarme.html small business] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/c4tracr.html international phone directory] [http://www.libertytitlecorp.com/templates_c/150/rolcobug.html huge fucking dildo] [http://www.davidgrover.com/gallery/albums/July12/acelwdard.html make your own bingo cards] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/quaalcr.html electric fireplace] [http://yellowshoe.com.au/tips/wp-content/themes/yellowshoe/picture/zarcas.html fast and the furious car] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/chialcot.html continental] [http://daintreehermitcrabs.com/home/conf/profiles/files/dronwro.html online marketing solution internet business promoter] [http://peopleit.net/store/admin/images/logo/thumbs/baszlachi.html gucci eyewear] [http://justgemsofsa.net/skin_cache/cacheid_1/vartasi.html hotmatchup] [http://www.apxuf.org/e107_docs/help/English/Files/domzelzar.html china girl] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/dombrdomr.html kitchen design gallery] [http://www.1800topsoil.com/blog/wp-content/uploads/images/roletc.html outward bound new york] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/dronacba.html modular buildings] [http://www.squadwerks.com/knowledge_base/admin/images/thumbs/tracfan.html antique appraisers] [http://www.apxuf.org/e107_docs/help/English/Files/caroldelb.html neck strap mp3] [http://longlifelighting.com.au/news/wp-content/uploads/images/noricacd.html whey] [http://marketingop.us/wp-content/uploads/2006/07/eninpas.html suiced poems] [http://www.jasonmichaelbrown.com/search-engine-marketing/images/bocnacnai.html indigo rose software design] [http://yellowshoe.com.au/tips/wp-content/themes/yellowshoe/picture/alorbocde.html dvdfab register code] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/pasbrc.html 64 ford fairlane for sale] [http://wiicentral.net/orders/images/images/ennofa.html nerja rentals] [http://yellowshoe.com.au/tips/wp-content/themes/yellowshoe/picture/monhent.html uk holidays] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/fokcoba.html canopy tent] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/racbugel.html exchange 5.5 owa hangs] [http://www.usedhomeschoolcurriculum.com/Themes/default/fonts/Candice/gif/bugget.html quote from meet the parent] [http://www.rides4u.com/images/rides/thumbs/ztavarf.html fort worth home sites] [http://www.trpservices.com/userfiles/image/001/sitemap.html map] [http://bubs-bibs-n-burps.com/oscommerce/includes/languages/english/images/pics/deracdell.html lets get physical] [http://justgemsofsa.net/skin_cache/cacheid_1/sedalr.html totally free sample] [http://www.squadwerks.com/knowledge_base/admin/images/thumbs/domreko.html lesbian love scenes in movies] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/cnatrc4tp.html radar detection units] [http://www.knifeshq.com/board/images/basfaacc.html novo naprox ec] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/zelboc.html epson printer] [http://autographshop.com.au/category/uploadedfiles/thumbs/acmonf.html lost prophets] [http://www.fineartpost.com/gallery/albums/album03/baslaet.html kathy lim wichita falls] [http://www.1800topsoil.com/blog/wp-content/uploads/images/necotroc.html japanese girl in uniform] [http://blog.pandorabraceletsusa.com/wp-content/themes/intrablog/images/icons/reorerorw.html the donner party] [http://www.apxuf.org/e107_docs/help/English/Files/trocred.html new york weekly newspaper] [http://www.fineartpost.com/gallery/albums/album03/canedeno.html 800 directory] [http://daintreehermitcrabs.com/home/conf/profiles/files/acelel.html 16 year old german models] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/elcaolo.html beautiful italian women] [http://www.latestdiscountvouchers.co.uk/rss/sitemap/racfuviko.html private investigation agency] [http://www.holisticvitamins.com/shop/images/large/dvd/thumbs/kocaenal.html bachelor party games] [http://www.davidgrover.com/gallery/albums/July12/delviordo.html enema wife punish] [http://www.rides4u.com/images/rides/thumbs/olocenetl.html 40 birthday greetings] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/ereltdr.html hot busty women 40] [http://www.holisticvitamins.com/shop/images/large/dvd/thumbs/reltroc.html mlt] [http://historicmatewanhouse.com/guestbook/upload/preview/pics/locaxch.html florida key west vacation rental] [http://www.holisticvitamins.com/shop/images/large/dvd/thumbs/fazelkoe.html whitman] [http://yellowshoe.com.au/tips/wp-content/themes/yellowshoe/picture/alfokf.html personal] [http://www.autosafetymagnets.com/blog/wp-content/uploads/images/botalabor.html fruitcake lady] [http://www.booknestguides.com/fishysearch/images/flags/thumbs/talogo.html online multiplayer games] [http://www.trpservices.com/userfiles/image/001/darchi.html cool groomsmen gifts] [http://peoplehosting.com.au/sitedesigner/sitebox_temp/cache/zarace.html unlisted phone] [http://www.smartfindsmarketing.com/blog/wp-content/uploads/avatars/fevdronr.html mary pope osborne author] [http://www.sghq.com/catalog/images/banners/new/zelfevg.html 1.8t] [http://blackacres.net/forum/images/avatars/gallery/pics/fokbocb.html root] [http://oyido.net/blog/wp-content/uploads/2007/03/zfiracz.html tld] [http://www.trpservices.com/userfiles/image/001/rolour.html nevada trust attorney] [http://autographshop.com.au/category/uploadedfiles/thumbs/vibase.html chili recipe white] [http://www.davidgrover.com/gallery/albums/July12/fibrsaric.html xp activation] [http://www.rides4u.com/images/rides/thumbs/ricvartr.html ellis island]
{{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: