WiseNPC01:Look, run and walk

From Valve Developer Community
Jump to navigation Jump to search


This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

Introduction

Note.pngNote:This is part of a series of tutorials on NPC’s.

To make the NPC look in a direction or to run and walk can be done with a scripted_sequence.

Look, run and walkl

In this example we are going to:

  • Wake Alyx.
  • Make her to look in our direction.
  • Make her run far away.
  • Finally she will walk back then die.

We are not going to use Face Poser for this. We are not going to use scripts that need to be loaded.

The first thing to do is place your NPC in the map and give it a name.

I’ve created a displacement for the floor area to illustrate something. The info_node_hint entities on the ground are necessary and will not work if they are buried in the displacement. Raise them up above displacement floors.

For this example I’m using 3 scripted_sequence entities to control Alyx.

WiseNPC01 02.jpg

Creation

Give each of your scripted_sequence entities a name. Set the Target NPC property to the name of your NPC, in this example it’s alyx.

The Move to Position property is the one that will do the work for us. For each of the 3 scripted_sequence entities Move to Position is:

  • alyx_seq01 No - Turn to Face
  • alyx_seq02 Run
  • alyx_seq03 Walk

The scripted_sequence has a Next Script property you can use.

In this example our second scripted_sequence has alyx_seq03 specified for the Next Script. So when Alyx runs to script #2 she will then walk to #3.

To begin the sequence of events I’m using a logic_auto. No changes are made to the logic_auto but these outputs are added:

Class: logic_auto
Keyvalues Comments
My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnMapSpawn alyx wake
Entity-output-icon.png OnMapSpawn alyx_seq01 BeginSequence 3.00
Entity-output-icon.png OnMapSpawn alyx_seq02 BeginSequence 5.00

On the ground between the scripted_sequence entities I’ve placed info_node_hint entities to give the NPC a walking path. Even with the scripted_sequence entities setup properly your NPC won’t walk or run without the info_node_hint entities.

At the final scripted_sequence I’ve created a trigger_once to kill the NPC.

Class: trigger_once
Keyvalues Comments
My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnTrigger alyx SetHealth 0


In each of these outputs alyx is the name of our NPC Alyx.

When the map loads the logic_auto will begin the sequences, when Alyx gets to sequence #2 it will activate sequence #3 and when Alyx gets to sequence #3 she will step into the trigger and activate the output above, which will cause her to die.

See also