[Unity Plugin] Summary of AI Behavior Tree Usage

Reference link:

https://blog.csdn.net/linxinfa/article/details/72937709

https://blog.csdn.net/wanghaodiablo/article/details/52587364

https://blog.csdn.net/q414620221/article/details/78596732

 

0. Node introduction

In general, you only need to extend the Conditional and Action nodes, and the Decorator and Composite nodes only need to use the built-in ones.

For the Conditional node, return success or failure according to the judgment condition.

For the Action node, in addition to success or failure, there is also a Running state, indicating that the node has not been executed yet, and the node continues to be executed in the next frame.

For the Composite node, here is a direct reference to the link:

a.Sequence:

b.Selector:

c.Parallel

 

1. The life cycle of the behavior tree

In general, when a tree has no nodes to continue execution, the life cycle of the tree ends.

a. Set the float variable num to 0. The logic below is to output "greater than 0" if num is greater than 0, otherwise output "less than or equal to 0". This tree is only executed once.

The b.repeater node checks repeat forever, and the tree will continue to execute after it is executed once.

c. Change the num value to 1, add an Action node, and return to Running. In this way, the behavior tree will be stuck in the Action node, will not continue to execute other nodes, and the life cycle will not end.

 d. Because the Action node returns Running, the behavior tree has not been executed, the repeater node does not work, and the Conditional node is only executed once.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324641815&siteId=291194637