This tutorial will lead you to familiarize yourself with the behavior Designer of the behavior tree plugin. This tutorial does not appear too much code, so it is also suitable for planning learning. You will learn a new animation and AI solution that uses behavior designer to design the playback logic of the animation and the AI's behavioral logic, if you've ever used playermaker so good, you can behavior The designer is considered an enhanced version of Playermaker but differs from Playermaker. Of course I'm not here to promote this plugin, but to understand another design idea. Of course, in the current domestic behavior designer plug-in Chinese information is scarce, you can also read the document as a document. If you are interested please continue to see below
We use this technique in order to solve the animation problem, with AI problems, first talk about what kind of problems we have encountered.
1. When the AI is complex enough, I find that the FMS has been written in a code of the mire, want to continue to maintain is very weak
2. When we use Unity's own animated state machine system, it becomes like this, of course, you do not want to change is not a physical activity, but I want to tell you that your teammates may be in some animation in some of the things called animation frame events, And this kind of thing requires you to select one and see if the animation file has been changed, and if it's too big for someone else to take over, it's "impossible."
Basic concepts
Composites
Here the "combination" full name should be "Combined node control (management) category", as the name implies under this entry, several options are called "Control node" to standardize the process of the behavior tree from the highest latitude. The specific breakdown is the following several
Parallel parallel node all nodes subordinate to this node will be executed together, where one execution returns false and the Parallel node returns false
Parallel Selector Parallel Select Node all nodes subordinate to this node as long as there is a return success, the Parallel Selector node returns success
Note: The above two nodes are parallel, i.e. all subordinate nodes are executed concurrently
Proiorty Selector Preferred Select Node all nodes subordinate to this node are executed sequentially until they return success
Random Selector Randomly Select nodes all nodes subordinate to this node are executed randomly until one of them returns success
Ramdom Sequence randomly selects a queue node all nodes subordinate to this node are randomly executed until one of them returns false
Selector Select Node all nodes subordinate to this node are executed sequentially until return true
Selector Evaluator Compute the selection node (let's call it, this noun translates the advantages of a mouthful) this node subordinates all the nodes in order to return to success, there is a situation to return the running state and interrupt, that is, a node is ticked
Sequence Order node all nodes subordinate to this node are executed sequentially until false is returned
Decorators
Decorative nodes should be composites branch nodes, and decorative nodes are generally used to modify the judgment, such as this modifier can be "until ... Success "," Until ... Failed
Conditional Evaluator Conditional Compute node This node is executed until success is returned, and there is a situation where it returns to the running state and interrupts, that is, a node is ticked.
Interrupt Interrupt (switch) node the first time this node executes to true the second time is false
Inverter contravariant node This node's child nodes, such as return success he can change the result to false and vice versa.
Repeater Repeat node This node can set the number of times the node is repeatedly executed
Return Failure/return Success I'm not going to explain.
The Task Guard task is meant to be a guard, so this node is telling us that we can use him to restrict the node's child nodes from being accessed by two or more tasks at the same time, in other words, the node can set its child nodes to be accessed by several tasks (the rest of the nodes) at the same time. Similar to multi-threaded access to unified resources we use the lock.
Until fuilure/until Success until ... Return false/know ... Return success These two items I don't think it's necessary to explain, but the literal meaning is enough to explain everything.
Actions
Action or behavior, such as "Attack" "Chase"
Action has three major classes, the first class is the underlying API, the second class is basic monobehavior operations such as Animator,animation,behavior, and so on, the third class for the secondary API is the use of reflection processing, Of course, this big class implies that the loss of performance should be used with caution.
Only the necessary API explanations are selected here, and the rest of you can read
Behavior Tree Reference This node allows the Getexternalbehaviors method to be overridden in the script of this node, that is, you can specify a behavior tree at run time to run under the current node! (Dynamic specified behavior tree)
Preform interuption This node allows users to break tasks that are added to the node list (many tasks can be done)
Restart Behavior Tree Restart behavior
Stop Behavior Tree Stop behavior
In addition the action general our program needs to extend to the planning configuration will refer to how to extend the action itself.
Conditionals
Used for conditional comparisons, such as whether "is null" "is in a state" "Whether a message is received" "is equal to a value"
As the most easily understood conditionals in the behavior tree, most of its basic APIs start with "is have XXX", as the name implies
How to Extend (program)
Create a custom behavior (action) or node
Related documents
Http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=5
Values set using Runtime (runtime)
There are two types of values set in the editor that require a preset value in a node when using a functional node, and a value that can be accessed globally
Add pause time for the wait node
Add globally accessible values
The float value you just set can be used at non-runtime
Of course, you can also use global values
I'm done. Accessing values using the editor now it's time to get these values dynamically using the runtime, the code is simple
Related documents
http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=54
Conclusion
How to extend this column in this article I think there is no need to write, but still slightly write a little bit, in fact, the code part of my website link can be directly copied code on the website also has video YouTube need FQ. Good luck ~
Getting started with the Behavior Designer behavior tree