Ru/Prefab: Difference between revisions

From Valve Developer Community
< Ru
Jump to navigation Jump to search
mNo edit summary
Line 4: Line 4:
}}
}}


'''Префаб''' означает '''предварительно созданный''', и является отдельно сохраненным объектом, состоящим, как правило, из разных частей - брашей, пропов или сущностей. Система префабов позволяет легко хранить части ваших уровней, которые можно использовать неоднократно. Примеры полезных префабов включают коридоры, столбы, специально установленные сущности, и т.д..
'''Префаб''' означает '''предварительно собранный''', и является отдельно сохраненным объектом, состоящим, как правило, из разных частей - брашей, пропов или сущностей. Система префабов позволяет легко хранить части ваших уровней, которые можно использовать неоднократно. Примеры полезных префабов включают коридоры, столбы, специально установленные сущности, и т.д..


Префабы - это просто маленькие файлы карт (.[[VMF]]), которые содержат только ваш префаб. Эти файлы хранятся в определенной папке, обычно <code>\sourcesdk\bin\prefabs</code>, чтобы [[Valve Hammer Editor|Хаммер]] мог легко их найти и вставить в ваш уровень.
Префабы - это просто маленькие файлы карт (.[[VMF]]), которые содержат только ваш префаб. Эти файлы хранятся в определенной папке, обычно <code>\sourcesdk\bin\prefabs</code>, чтобы [[Valve Hammer Editor|Хаммер]] мог легко их найти и вставить в ваш уровень.

Revision as of 20:47, 18 August 2015

Template:Otherlang2

Префаб означает предварительно собранный, и является отдельно сохраненным объектом, состоящим, как правило, из разных частей - брашей, пропов или сущностей. Система префабов позволяет легко хранить части ваших уровней, которые можно использовать неоднократно. Примеры полезных префабов включают коридоры, столбы, специально установленные сущности, и т.д..

Префабы - это просто маленькие файлы карт (.VMF), которые содержат только ваш префаб. Эти файлы хранятся в определенной папке, обычно \sourcesdk\bin\prefabs, чтобы Хаммер мог легко их найти и вставить в ваш уровень.

Примечание: В играх orangebox, убедитесь, что используете \sourcesdk\bin\orangebox\bin\prefabs

Префабы можно выстраивать по иерархии, просто добавляя их в подпапки каталога \prefabs. Это позволяет сортировать их на основе принадлежности к карте или моду, тем самым облегчая поиск.

Создание префабов

Следующие шаги позволяют создавать префабы в Хаммере:

  1. Если префабы предназначены для взаимодействия с поименованными объектами внутри себя, в конце имени каждого объекта добавляем маркер "_&i". См. ниже Маркер префабов.
  2. Выделите объекты, которые нужно добавить в префаб (зажав Ctrl).
  3. Если вы планируете вставлять префаб, используя Entity Tool, то начало координат (0,0,0) вашей карты будет использовано в качестве точки отсчета, поэтому желательно перенести выбранные объекты в эту точку и центрировать префаб по ней.
  4. Нажмите кнопку Create Prefab на панели объектов, или выберите команду Create Prefab в меню инструментов. (Горячая клавиша: Ctrl+R)
  5. Откроется диалог Save As..., показывая каталог префабов Хаммера. Впишите имя файла и сохраните префаб, нажав кнопку Save. Template:Note:ru Template:Bug:ru
  6. Теперь новый префаб будет доступен для вставки на панели объектов.

Маркер префабов

К именам сущностей внутри префаба можно добавить специальный маркер "&i", так то на карте им будет присвоен уникальный номер. Маркер может включаться в targetname, inputs and outputs, и т.д.. Все маркеры в префабе будут заменены на тот же номер. Это позволяет сущностям внутри префабов не ссылаться на другие префабы.

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.pngПримечание:Other values, like specific Brush faces attached to prefab env_cubemaps, cannot be saved, and have to be reset upon each insertion.

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

Tip.pngСовет: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.

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.pngСовет: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 needs to be ungrouped before individual components can be moved.

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.
  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.

Available prefabs

For a list of prefabs that are already available in the Source SDK, see Category:Prefabs.

See also

External links

The following sites host custom made prefabs and models: