Path Nodes: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
Line 2: Line 2:


For more information on pathfinding, see [[Pathfinding]].
For more information on pathfinding, see [[Pathfinding]].
= What are Path Nodes? =


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).
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).
Line 7: Line 9:
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).   
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.
Although path nodes have a directional arrow in the editor, it does not appear to mean anything in most cases.  It has no effect on what direction AI face except when used on a path_turn node.
 
= How to use Path Nodes =
 
Path nodes are placed like any other entity (RMB and select "add entity", then scroll to "paths").  They show up as an orange box in the editor.
 
Path nodes are useless if they are not linked to another entity (either an AI or another node).  In order to link them, you use the "target" property.  This tells the 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" when the map starts.  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.
 
Behaviour nodes activate behaviour in order.  In other words, if you want an AI to reach a path_corner, then turn to face a direction, then wait for a time, then play an animation, you need to link the nodes in that order. 
 
path_corner ---> path_turn ----> path_wait ----> path_cycleanim -----> next path_corner


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 ==
== path_corner ==
Line 16: Line 27:
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.
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)''
A single entity (path node or AI) can target more than one path_corner; D3 will randomly choose between the targetted nodes.  Use the following syntax:  ''(actually this syntax needs to be double checked)''


  target path_corner_1
  target path_corner_1
Line 22: Line 33:




''(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)''
''(At the moment, targetting more than 2 path_corners from the same entity does not seem to work (possibly a DR bug).''


In the example below, the AI will walk to A, then turn and walk to B, then stop.
In the example below, the AI will walk to A, then turn and walk to B, then stop.
Line 33: Line 44:
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).   
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_wait node appears as a small orange 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...
A path_wait node should have a "wait" property (it's possible there is a default wait value if you don't add one), 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
     * wait 30
Line 46: Line 57:
[[image:pathfinding3.jpg]]
[[image: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--in both cases the AI will walk directly from A to B.
Note that it does not matter '''where''' the path_wait node is placed.  The AI does not actually follow the orange lines (this is not really intuitive, I know).  The example below would cause the exact same behaviour as the example above--in both cases the AI will walk directly from A to B.


[[image:pathfinding4.jpg]]
[[image:pathfinding4.jpg]]
Line 63: Line 74:
''It might also default to facing the path_turn entity itself. (have to test this)''
''It might also default to facing the path_turn entity itself. (have to test this)''


---------------------------------


''(I have yet to test the following)''
= Untested Nodes =
 
I have not personally tested the following, so I'm just going by their editor descriptions.  They may or may not work as described.


== path_anim ==
== path_anim ==


This is a behaviour node that makes the AI play an animation, once.  When that animation is done, it proceeds to the next target (if any).  The editor says something about the direction affecting where the AI faces while the animation is played.
This is a behaviour node that makes the AI play an animation, once.  When that animation is done, it proceeds to the next target (if any).  This could be used to make an AI walk over to a bookshelf and play a 'reaching out' animation, for example.  The editor says something about the direction affecting where the AI faces while the animation is played.
 
Questions:  what property is used to select the animation?  Can more than one be added to the same node?  What happens if a path_corner targets two different path_anims (hopefully D3 picks one at random, but that needs confirmation)?


== path_cycleanim ==
== path_cycleanim ==


The AI stays in place and loops a the selected animation, either for a specified amount of time or until triggered.
The AI stays in place and loops the selected animation, either for a specified amount of time or until triggered.
 
== path_lookat ==


This does not stop the AI, but they will turn their head and look somewhere specific as they walk.  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). This is useful if you want to make sure an AI is looking at a specific spot (or away from a certain spot) during their patrol.


== path_waitfortrigger ==


== Targetting More than one Behaviour Node ==
Waits at a given place until triggered, then proceeds to the next target. 


Behaviour nodes activate behaviour in order.  In other words, if you want an AI to reach a path_corner, then turn to face a direction, then wait for a time, then play an animation, you need to link the nodes in that order. 
== path_hide ==


  path_corner ---> path_turn ----> path_wait ----> path_cycleanim -----> next path_corner
Deactivates and stops rendering the AI. Used to remove "ambient AI" from the map when they have served their purpose.


== path_show ==


Starts rendering the AI.  I would assume this one would be linked to a path_waitfortrigger, to create AI that spawn when triggered.


== 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_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.)
Questions:  How do you define who the AI attacks?


== path_interact ==


* '''path_waitfortrigger''' ( waits at a given place until triggered, then moves to next path_* )
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, not for inventory items and moveables. 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.  AI will use normal doors and elevators without needing a path_interact (confirmation needed).  However, this could be used to make AI turn on lightswitches, open mechanical doors, etc.
* '''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.

Revision as of 16:02, 10 December 2008

originally written by Springheel

For more information on pathfinding, see Pathfinding.

What are Path Nodes?

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 mean anything in most cases. It has no effect on what direction AI face except when used on a path_turn node.

How to use Path Nodes

Path nodes are placed like any other entity (RMB and select "add entity", then scroll to "paths"). They show up as an orange box in the editor.

Path nodes are useless if they are not linked to another entity (either an AI or another node). In order to link them, you use the "target" property. This tells the 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" when the map starts. 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.

Behaviour nodes activate behaviour in order. In other words, if you want an AI to reach a path_corner, then turn to face a direction, then wait for a time, then play an animation, you need to link the nodes in that order.

path_corner ---> path_turn ----> path_wait ----> path_cycleanim -----> next path_corner


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 the targetted nodes. Use the following syntax: (actually this syntax 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).

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 orange box. It has a directional arrow, but that has no affect on which direction the AI faces.

A path_wait node should have a "wait" property (it's possible there is a default wait value if you don't add one), 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 actually follow the orange lines (this is not really intuitive, I know). The example below would cause the exact same behaviour as the example above--in both cases the AI will walk directly from A to B.

Pathfinding4.jpg


path_turn

This behaviour node tells an AI to turn in place to face a chosen direction. It does not make the AI walk anywhere. This is the one node where the directional arrow does seem to matter--the AI seems to face the same direction as the arrow. Alternately, you can use the property "angle" and the values below:

  • 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. (have to test this)


Untested Nodes

I have not personally tested the following, so I'm just going by their editor descriptions. They may or may not work as described.

path_anim

This is a behaviour node that makes the AI play an animation, once. When that animation is done, it proceeds to the next target (if any). This could be used to make an AI walk over to a bookshelf and play a 'reaching out' animation, for example. The editor says something about the direction affecting where the AI faces while the animation is played.

Questions: what property is used to select the animation? Can more than one be added to the same node? What happens if a path_corner targets two different path_anims (hopefully D3 picks one at random, but that needs confirmation)?

path_cycleanim

The AI stays in place and loops the selected animation, either for a specified amount of time or until triggered.

path_lookat

This does not stop the AI, but they will turn their head and look somewhere specific as they walk. 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). This is useful if you want to make sure an AI is looking at a specific spot (or away from a certain spot) during their patrol.

path_waitfortrigger

Waits at a given place until triggered, then proceeds to the next target.

path_hide

Deactivates and stops rendering the AI. Used to remove "ambient AI" from the map when they have served their purpose.

path_show

Starts rendering the AI. I would assume this one would be linked to a path_waitfortrigger, to create AI that spawn when triggered.

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.

Questions: How do you define who the AI attacks?

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, not for inventory items and moveables. 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. AI will use normal doors and elevators without needing a path_interact (confirmation needed). However, this could be used to make AI turn on lightswitches, open mechanical doors, etc.