User Tools

Site Tools


behavior-trees

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
behavior-trees [2020/07/17 14:42] maximebehavior-trees [2021/07/29 11:56] (current) maxime
Line 2: Line 2:
  
 You can find an example of behavior tree and behavior tree node creation in the following mods: You can find an example of behavior tree and behavior tree node creation in the following mods:
-  * ''Example 01'' (file ''scripts/wooden_keep_guard_locator.lua'')+  * ''Example 01'' (file ''wooden_keep_guard_locator.lua'')
   * ''Example 02'' (file ''scripts/behavior_tree.lua'').   * ''Example 02'' (file ''scripts/behavior_tree.lua'').
  
Line 45: Line 45:
 ==== Functions ==== ==== Functions ====
  
-A leaf node has three basic functions: ''Init'', ''Update'', and ''Finish''. The ''Update'' function takes the level (''[[api:level|LEVEL]]'') and the tree instance (''[[api:behavior_tree_instance|BEHAVIOR_TREE_INSTANCE]]''as parameter, and returns a ''[[api:behavior_tree_node_result|BEHAVIOR_TREE_NODE_RESULT]]''.+A leaf node has three basic functions: ''Init'', ''Update'', and ''Finish''. The implementation of ''Init'' and ''Finish'' are optional. 
 + 
 +=== Init === 
 + 
 +''void **Init**(//instance//)'' 
 + 
 +^ Name ^ Type ^ 
 +| //''instance''// | ''BEHAVIOR_TREE_INSTANCE''
 + 
 +=== Update === 
 + 
 +''BEHAVIOR_TREE_NODE_RESULT **Update**(//level//, //instance//)'' 
 + 
 +^ Name ^ Type ^ 
 +| //''level''// ''LEVEL'' 
 +| //''instance''// ''BEHAVIOR_TREE_INSTANCE'' 
 + 
 +=== Finish === 
 + 
 +''void **Finish**(//instance//)'' 
 + 
 +^ Name ^ Type ^ 
 +//''instance''// | ''BEHAVIOR_TREE_INSTANCE'' |
  
 When a node is executed, the ''Init'' function is called first. Then, the ''Update'' function is called until it doesn't return ''[[api:behavior_tree_node_result|BEHAVIOR_TREE_NODE_RESULT.PROCESSING]]''. Finally, the ''Finish'' function is called. When a node is executed, the ''Init'' function is called first. Then, the ''Update'' function is called until it doesn't return ''[[api:behavior_tree_node_result|BEHAVIOR_TREE_NODE_RESULT.PROCESSING]]''. Finally, the ''Finish'' function is called.
  
 You can access all of the node's variables in those functions with ''self''. You can access all of the node's variables in those functions with ''self''.
behavior-trees.1595011343.txt.gz · Last modified: 2020/07/17 14:42 by maxime

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki