WiseNodeLink: Navigating Obstacles

From Valve Developer Community
Jump to: navigation, search


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

Introduction

In this project:

  1. Alyx faces a body of water, has nowhere to go.
  2. Bridge lowers over water, Alyx can walk across but it’s blocked by a large crate.
  3. Alyx walks across and pushes crate out of the way.

The entities in this project can be used in a variety of ways. I created this as a general example. Instead of a bridge the obstacle could be a gate, etc. Instead of a crate the obstacle could be a turnstyle, etc. (sdk_d1_trainstation_01.vmf)

Creation

I’m using two scripted_sequence entities to get Alyx to walk. Notice the Move to Position property for both is Walk. Try not to place these too high above the ground where the NPC is walking. Raising them up will cause your NPC to jump as they transition. On the ground where Alyx will be walking I’ve placed info_node entities. Place these in good locations, don’t burry them in brushwork or displacements. To connect the nodes across the bridge I’ve used an info_node_link entity. This is a dynamic connection between navigation nodes. These can be turned on and off. In this example it starts Off and we turn it On when the bridge lowers. The crate obstacle in this project is prop_physics. It uses the World Model models\props_junk\wood_crate002a.mdl.

To get Alyx to push the crate out of the way I’m using a logic_navigation entity. You can use several of these in a map and they are very simple to place. The only property you have to assign is the Navigation Entity, which is the entity you want the NPC to push out of the way. Check the flags for Start on.

When the map starts I’m using a logic_auto to control all of the actions at once.

The outputs:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnMapSpawn bridge01 Press 0.00 Yes
Io11.png OnMapSpawn bridge01 Press 7.00 Yes
Io11.png OnMapSpawn link01 TurnOn 8.50 Yes
Io11.png OnMapSpawn ss01 BeginSequence 9.00 Yes

In the 4 outputs above:

  1. The bridge, func_rot_button, rises when the map starts.
  2. Seven seconds later the bridge lowers.
  3. Next the info_node_link is turned on.
  4. Finally the first scripted_sequence is called and Alyx begins her walk.
  5. As she gets to the crate she will push it out of the way to get to that scripted_sequence.
  6. Once she reaches the first scripted_sequence it will call the next, and last, scripted_sequence and Alyx will walk to it.

As you can see in a matter of minutes you can create methods for your NPCs that will allow them to overcome obstacles. If only it was that easy for us out here in the real world.

See also