Path Nodes

From The DarkMod Wiki
Jump to navigationJump to search

originally written by Springheel

For more information on pathfinding, see Pathfinding.

Path entities (or path nodes) are the things that you use to make your AI move around the map. Placing path nodes can take a little getting used to; hopefully this article will help (I'm far from an expert, but here's what I've discovered so far).

There are lots of different kinds of path nodes. It can sometimes help to think of them as "travel nodes" (nodes that AI will travel to) and "behaviour nodes" (nodes that tell AI how to behave at a certain point).

Although path nodes have a directional arrow in the editor, it does not appear to do anything. It has no effect on what direction AI face.

You must use the keyword "target" to tell AI what pathnode they should go to (or act on) next. If you type "target" "path_corner_1" in your AI property list, then your AI will walk to "path_corner_1". Without a "target" property, your AI will not go anywhere. Once you add a "target" property to either your AI or another node, you should see an orange line connecting the two entities.

path_corner

Probably the most common path node, this is a "travel node". AI will walk from their current position to this node in as straight a line as possible. This node must be on the ground and in an area AI can reach. See Pathfinding for more information on how to help AI go from one node to another.

To make AI patrol an area, each path_corner node can target the next one in sequence. If AI reach a node that does not target anything, they will stop there and no longer move without player interaction.

A single entity (path node or AI) can target more than one path_corner; D3 will randomly choose between them. Use the following syntax: (actually this needs to be double checked)

target path_corner_1
target_2 path_corner_2


(At the moment, targetting more than 2 path_corners from the same entity does not seem to work (possibly a DR bug). You can target more than two behaviour nodes, however)

In the example below, the AI will walk to A, then turn and walk to B, then stop.

Pathfinding2.jpg

path_wait

This is a behaviour node. It does not tell an AI to move anywhere. This node tells an AI to wait in an idle state for a given amount of time. Once that time is up, the AI will proceed to whatever the next target is (a path_node with no target is pretty pointless).

A path_wait node appears as a small box. It has a directional arrow, but that has no affect on which direction the AI faces.

A path node should have a "wait" property, with the number of seconds the AI should wait there before proceeding. It can also have a "random" property which will vary the repeat time. Random n varies the wait time randomly by plus or minus n seconds. So for example...

   * wait 30
   * random 10 

...will cause the AI to wait between 20 to 40 seconds before proceeding.

In the following example, the AI walks to A and waits there for the required amount of time, then turns and proceeds to B.

Pathfinding3.jpg

Note that it does not matter where the path_wait node is placed. The AI does not follow the orange lines (this is not really intuitive, I know). The example below would cause the exact same behaviour as the example above.

Pathfinding4.jpg


( waits, standing completely motionless at a given place for a given amount of time, then moves to next path_* ) - (tested OK - Fidcal)


  • path_anim (plays an anim once when the AI gets to this point in space, then goes on to the next path entity when the anim is done playing)
  • path_cycleanim (stays in place and loops an anim, either for a specified amount of time or until triggered)
  • path_lookat (for the next wait seconds, turn head to look at the entity given by the focus spawnarg (defaults to looking at the path_lookat entity itself). Immediately keep moving to next path_* in sequence.)
  • path_turn Turns in place to face a chosen direction. Give it the property angle from 0 to 360 with the direction you wish the player to be facing, eg, as follows in plan (top) view...
    • 0 = East (X)
    • 90 = North (Y)
    • 180 = West (-X)
    • 270 = South (-Y)
    • 360 = East(X)

It might also default to facing the path_turn entity itself. Try also focus with an entity name to get it to face that entity (not tried)

  • path_waitfortrigger ( waits at a given place until triggered, then moves to next path_* )
  • path_hide (deactivates and stops rendering the AI)
  • path_show (starts rendering the AI)
  • path_attack (Used to script AI attacking a particular enemy, for scripted sequences I guess. AI will continue on to the next path entity if it kills the enemy)
  • path_interact This lets the AI interact with an entity (for example a button) in a similar way to frobbing. This will only work for buttons etc, but not for inventory items and moevables. The AI will stop and look at the entiy while interacting, but not walk to it, so a path_corner next to the entity is required.