Destinations/Turret Tutorial

From Valve Developer Community
< Destinations
Revision as of 13:47, 16 June 2016 by Lawrencey (talk | contribs) (Creating a new Turret tutorial - covering triggers, animation, and sound)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Triggers, Animation, and Sound

In this tutorial we will be recreating the singing turrets of the “Turrets” Destination, and learn about some more advanced Hammer features. If you haven’t seen “Turrets” yet, check it out in the Destinations Viewer – it will be one of the default Destinations.

Topics we will cover in this tutorial:

  • Models with animation
  • Trigger Volumes and Triggers
  • Sound
  • Delayed Triggers

Some background on the Turrets Destination: This song and dance was originally slated to be part of Portal 2. There was going to be a sequence where you fell among a colony of turrets, and they became obsessed with making you a turret wife?? (Tristan help)

What you will need

Create a new addon from Turrets

Tutorial placelight.png
  • Open Destination Workshop Tools
  • Select “Turrets” and click “Create New Addon from Selected”
    • We will be using assets from the Turrets example map in this tutorial

Create a base map

Tutorial placelight.png
  • Open Hammer and create a new map with:
    • A player start
    • A floor
    • A light
    • A teleport mesh on the floor
  • For more instructions on how to do this, look at the first few steps of the Getting Started Tutorial

Singing Turret model

  • Go to the Asset Browser and find “turret.vmdl” (you can perform a search in the Asset Browser to find this quickly)
  • Double click on turret.vmdl to open the model in Model Editor.
  • In Model Editor, you’ll see a panel on the left called Outliner. In here there’s a section called "Animations” - these are the animations associated with the model
  • This model has four singing and one idle animation associated with it - click on these and you can see the model going through the animations (some have a delay and don’t start moving immediately)
  • Each animation was timed to a specific piece of audio before bringing it into Workshop Tools.
  • In our Destination, we will be using this same model four times, activating a different animation on each model.

Bring the Turret into Hammer

  • Go back to the Asset Browser, and drag turret.vmdl into Hammer.
  • If you look at Object Properties (should be a panel in the bottom right) for this turret, you'll see it came in as a "prop_static".
  • Since we want this model to be animating, we'll need this to be "prop_dynamic". Click drop down in Object Properties > Class or type "prop_dynamic" in this field and hit Enter.

Creating a Trigger Volume

  • Using the Block tool, create a box in your map.
  • Resize this box to be taller than the player start.
    • You can use the Scale tool “E” to do this.
    • Alternatively you can click the “Faces” button at the top of the screen, and click the top of the box. Then hit the Transform tool “T” and drag the face up to resize the box this way. Make sure you go back to “Objects” mode after you are finished scaling the box.
  • In the Object Properties panel, select "tie selected meshes to entity".
  • It will default to "trigger_multiple" which is what we want.
  • In the Materials tab of the bottom panel, do a search for “trigger”.
  • Drag the toolstrigger.vmat material onto the box.

Defining the Trigger

  • Double click on your trigger volume box to see the full Object Properties window
  • Select the Outputs tab
  • Click the “Add” button on the bottom of the window to add a new output
  • The “my output named” field defines how you would like this trigger to be activated. Select or type "OnTrigger"
    • There are many ways to do what we are trying to accomplish here, but for the purposes of this tutorial we'll use OnTrigger
  • The “Target entities named” field defines what you would like to be trigged. Select the eyedropper tool.
    • Click on the turret in your map to select it as the thing to be triggered.
    • You will be prompted to name it - name it turret_lo.
    • You could have also named this turret in the object properties panel.
  • The "Via this input" field defines what you want your target entity to do.
    • We want the model to perform an animation, so type or select “SetAnimation”
  • "With parameter override of" – defines the input more specifically.
    • We want it to perform the “turret lo” animation, but we need to make sure we have the exact name
    • Go back to the turret in the Model Editor.
    • Look at the names of the animations in the left panel.
    • This will be the “low” turret, so we want it to perform the "3penny_lo" animation.
    • Go back to Hammer, and in the Object Properties window under “With a parameter override of”, type "3penny_lo".
  • Now we’ve defined it so that when this box is triggered, this specific turret will perform this specific animation.
  • One last thing – let’s define how long it will take to repeat when triggered.
    • Click the Properties tab of Object Properties. At the bottom is a field called “Delay Before Reset”. By default, it’s set to “1”, which means it will repeat itself every 1 second. We don’t want this, but we do want it to repeat after it’s done with the song.
    • Type 110 in the “Delay Before Reset” field, so it will repeat after the song is finished (110 seconds).
      • We can figure this out by looking at the model in Model Editor and seeing how many frames there are in the animation. In this case, there are 3125 frames – divided by 30fps, it’s around 105 seconds. So with a little bit of buffer, that’s a 110 second delay before reset.

Trigger Teleport

  • The trigger volume is invisible to the user when in VR, so we need a way to get them to jump there.
  • A teleport marker will do this job nicely.
  • Select the entity tool, and make the Entity Class “vr_teleport_marker”.
  • Click to drop a teleport marker and move it so that it’s inside the trigger volume, flush with the ground.
  • You may need to move it with the Translate (T) tool.

Test your map

  • Press F9 to build and save your map
  • Try it out in VR. When you teleport to the teleport marker, you should see the turret begin to animate

Add a soundevent

  • The sounds and sound manifest file have already been created for this map. Now we will hook them up to play when triggered.
    • To see where they are and how they were hooked up, look in content/steamtours_addons/turrets/sounds, and content/steamtours_addons/turrets/soundevents.
    • In /soundevents, there is a file called soundevents_addon.vsndevts – when creating your own Destination with sounds, this is the file you will need to create and edit in order to use soundevents.
  • In Hammer, click the Entity button (light bulb icon).
  • Change the Entity Class to “point_soundevent”.
  • Click in your map to place a point_soundevent. Move it with the Translate (T) logo so that it’s hovering just above the turret. It doesn’t matter which direction the icon is pointing.
  • In the Object Properties panel, name this soundevent “turret_lo_sound”

Trigger the soundevent

  • Double click on your trigger volume box to open the full Object Properties window
  • Go to the Outputs tab and duplicate the animation trigger output that we created a few steps ago. There are copy and paste buttons at the bottom of the window.
  • ”My output named”: OnTrigger
  • ”Target entities named”: turret_lo_sound (you can also use the eyedropper here and click on your soundevent entity in the map)
  • ”Via this input”: StartSound
  • ”With a parameter override of” – to find the name of the sound we want to play, we’ll need to look in another file
    • Go to content/steamtours_addons/turrets/soundevents and open the soundevents_addon.vsndevts in a text editor
    • Here we can see that the name of the soundevent we want is “three_penny_lo”
  • Back in Hammer > Object Properties > Outputs, type “three_penny_lo” into the “With a parameter override of” field.

STILL DOESN’T WORK

  • Press F9 to build and test your map. When you teleport to the teleport marker, you should see the turret animating, and hear a sound clip that matches the animation.

Fill out the rest of the quartet

  • Now that you know how it’s done, it’s relatively simple to add the three other turrets with their own animations and sounds.
  • Select the turret and sound entity and pick the “Translate” tool. Shift+move the turret and sound entity to duplicate them.
  • Rename this duplicated turret to “turret_perc” in Object Properties “Name” field. Rename the duplicated sound entity to “turret_perc_sound.
  • Double click on your trigger volume and go to the Outputs tab.
  • Duplicate both the animation and sound outputs, and change the “Target entities named” fields to match your duplicated model and sound entity names respectively. You can also use the eyedropper tool to do this quickly.
  • Look in the Model Editor and the soundevents_addon.vsndevts file to see what names to enter for the “parameter override” fields for the animation and sound on this turret.
  • You should now have four Outputs on this trigger volume - set to make each turret do its own animation, and make each sound entity play its own sound.
  • Follow these steps two more times for the other two turrets – turret_mid and turret_hi – and you should end up with the four-part harmony + animations across all four turrets.