category
General Half-Life 2/Scripting
description
The bread and butter of SP level design, takes you through a basic script.
keywords
script, scripted, sequences, sequence, scripts, scripted_sequence.
We will be looking at how to get a barney to walk somewhere and wave and then walk to another place. Once you know the concept you can adapt it to other NPC and their animations.
First thing to do is set-up some entitles in your level. Place an npc_barney and two scripted_sequence entities in the map. Also drop a weapon_shotgun near the player.
Shown below:
What we are going to do is make the barney walk to the first scripted_sequence and then perform an animation and when down walk to the second scripted_sequence. We will be using the shotgun to trigger this, as soon as the player picks it up.
The first thing to do is open up the properties for the npc_barney and give it a name, in this instance barney1 will suffice
Next open up the scripted_sequence that you want the barney to walk to and perform his animation.
There are quite a few entries and they all have descriptions but we will be using the main ones here.
Name: Call it script1; this is so we can trigger it
Target NPC: Barney1
Action Animation: Type Wave in here, you can see a list of animations in the model viewer for each entity.
Move to Position: Choose Walk, this is how he will get there
Right, now you have done that go into the other scripted_sequence and set these fields:
Name: Script2
Target NPC: Barney1
Move to Position: Walk
Ok so we are done with the sequences, the barney will walk to the first one, wave and then walk to the second one. We are now going to set them up to link to each other using the Input/ Output system.
So first we want the shotgun to trigger the first script when it’s picked up, go in to it’s properties and go to the outputs tab, here is where we add things that this entity triggers, the input tab shows triggers coming in from other entities.
First hit Add
Then we choose OnPlayerPickup, this triggers the event when the shotgun is picked up.
Next we enter the entity we want to target, so this is script1, you can use the small pen icon to the right to click the entity you want to target in the 3D view as well.
We tell it to BeginSequence when this happens as well
And we can also put a delay in if we want.
Ok so at the moment it will trigger script1 to carry out it’s tasks when the shotgun is picked up, if you go into script1 and look at the Inputs you will see this effect in there.
The next thing to do is open up script1 and get it to trigger script2 after the barney is done waving, so go in to the output tabs and hit Add again.
Copy the above details, and now it should work. Try compiling the map and having a look. If it fails think logically at what each entity is doing and triggering, the I/O system makes this easy to see.
See him wave!
Related:
Example Map
Blink