Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
quick:bolt [2019/06/06 13:35] – victorzamora | quick:bolt [2019/06/06 13:44] – victorzamora | ||
---|---|---|---|
Line 14: | Line 14: | ||
* Nav Mesh Hit (from Unity). | * Nav Mesh Hit (from Unity). | ||
- | ![Type Options](https:// | + | ![Type Options](images:bolt: |
Finally, there are other two options under `Tools/ | Finally, there are other two options under `Tools/ | ||
Line 22: | Line 22: | ||
Start creating a new Behavior in the Behavior Bricks editor named, for example, | Start creating a new Behavior in the Behavior Bricks editor named, for example, | ||
- | ![First phase of the behavior tree](https:// | + | ![First phase of the behavior tree](images:bolt:First phase of the behavior tree.png) |
The body of the behavior will be linked to this `Sequence` node and will consist in three nodes: | The body of the behavior will be linked to this `Sequence` node and will consist in three nodes: | ||
Line 32: | Line 32: | ||
The first node of the behavior is a `bolt generic event` node in the behavior tree. A `bolt generic event` is a node that does not have input parameters, so we have just to add this node as first node in the `Sequence`. | The first node of the behavior is a `bolt generic event` node in the behavior tree. A `bolt generic event` is a node that does not have input parameters, so we have just to add this node as first node in the `Sequence`. | ||
- | ![Second phase of the behavior tree](https:// | + | ![Second phase of the behavior tree](images:bolt:Second phase of the behavior tree.png) |
Although the behavior does not have input parameters, we need to fill the name of the `custom event` as a constant value. This custom event name will must be the same as the `custom event` that we are going to create in Bolt. In this case, we write the name " | Although the behavior does not have input parameters, we need to fill the name of the `custom event` as a constant value. This custom event name will must be the same as the `custom event` that we are going to create in Bolt. In this case, we write the name " | ||
Now, we create a Bolt `macro` with a `custom event` named " | Now, we create a Bolt `macro` with a `custom event` named " | ||
- | ![PendingPath](https:// | + | ![PendingPath](images:bolt: |
As mentioned before, this `macro` checks if there is not still a path pending and if the remaining distance is less or equal than a threshold (in this example, 2) and, if so, return success. Note that the parameter of the custom event is used to call the `" | As mentioned before, this `macro` checks if there is not still a path pending and if the remaining distance is less or equal than a threshold (in this example, 2) and, if so, return success. Note that the parameter of the custom event is used to call the `" | ||
Line 70: | Line 70: | ||
Next, we have to add a `Flow Machine` to the enemy and, then, create a new `macro` called, for example, `BoltGetReachableRandomPoint`. The macro generates a random vector and taking the nav mesh calculates where the GameObject must go. | Next, we have to add a `Flow Machine` to the enemy and, then, create a new `macro` called, for example, `BoltGetReachableRandomPoint`. The macro generates a random vector and taking the nav mesh calculates where the GameObject must go. | ||
- | ![GetRandomReachablePoint](https:// | + | ![GetRandomReachablePoint](images:bolt: |
This `macro` must have a `Custom Event` module with number of arguments setted at two and the name of the event will be `GetRandomReachablePoint`. In this case, we have 2 parameters: the reference of the own Behavior Bricks node and the variable that we have just created. In addition, a `Return Main` module is necessary too. As in the previous node (Check Pending Path), it indicates the node what was the result of the execution. | This `macro` must have a `Custom Event` module with number of arguments setted at two and the name of the event will be `GetRandomReachablePoint`. In this case, we have 2 parameters: the reference of the own Behavior Bricks node and the variable that we have just created. In addition, a `Return Main` module is necessary too. As in the previous node (Check Pending Path), it indicates the node what was the result of the execution. | ||
Line 76: | Line 76: | ||
Now, we have to add the new node `GetRandomReachablePoint` in the behavior tree, as in the image below. | Now, we have to add the new node `GetRandomReachablePoint` in the behavior tree, as in the image below. | ||
- | ![Third phase of the behavior tree](https:// | + | ![Third phase of the behavior tree](images:bolt:Third phase of the behavior tree.png) |
In the Behavior Bricks editor create the variable `Max Distance` (must have the same name that the string that we add to the list in the code of `GetReachableRandomPoint` previously). | In the Behavior Bricks editor create the variable `Max Distance` (must have the same name that the string that we add to the list in the code of `GetReachableRandomPoint` previously). | ||
Line 82: | Line 82: | ||
The Behavior Bricks constant `Custom Event Name`, again, must have the same name as the `Custom Event` module from Bolt, in this case `Get Reachable Random Point`. | The Behavior Bricks constant `Custom Event Name`, again, must have the same name as the `Custom Event` module from Bolt, in this case `Get Reachable Random Point`. | ||
- | ![GetRandomReachablePoint_parameters](https:// | + | ![GetRandomReachablePoint_parameters](images:bolt: |
In the tab " | In the tab " | ||
- | ![GetRandomReachablePoint_parameters_editor](https:// | + | ![GetRandomReachablePoint_parameters_editor](images:bolt: |
### Custom Bolt Event: Variable Wait | ### Custom Bolt Event: Variable Wait | ||
Line 111: | Line 111: | ||
First, we create a Bolt `macro` `BoltVariableWait`, | First, we create a Bolt `macro` `BoltVariableWait`, | ||
- | ![variablewait_graphvariable](https:// | + | ![variablewait_graphvariable](images:bolt: |
This `macro` must have a `Custom Event` module with number of arguments setted at three and the name of the event will be `VariableWait`. In this case, we have three parameters: the reference of the own Behavior Bricks node and the variables that we have just created. In addition, a`Return Main` modules is necessary (for indicate the result of the execution). | This `macro` must have a `Custom Event` module with number of arguments setted at three and the name of the event will be `VariableWait`. In this case, we have three parameters: the reference of the own Behavior Bricks node and the variables that we have just created. In addition, a`Return Main` modules is necessary (for indicate the result of the execution). | ||
- | ![variablewait](https:// | + | ![variablewait](images:bolt: |
Next, in Behavior Bricks editor we have to put the variables `Min Time` and `Max Time` as blackboard variables and have to name the `Custom Event Name` as `VariableWait`. | Next, in Behavior Bricks editor we have to put the variables `Min Time` and `Max Time` as blackboard variables and have to name the `Custom Event Name` as `VariableWait`. | ||
- | ![variablewait_parameters](https:// | + | ![variablewait_parameters](images:bolt: |
In the tab `Blackboard` we set the value of `Max Distance` as 20, `Min Time` as 2 and `Max Time` as 4. | In the tab `Blackboard` we set the value of `Max Distance` as 20, `Min Time` as 2 and `Max Time` as 4. | ||
- | ![variablewait_parameters_BB](https:// | + | ![variablewait_parameters_BB](images:bolt: |
In some versions of Unity, default values do not work, so you have to put this values in the `Behavior Executor` component as in the image. | In some versions of Unity, default values do not work, so you have to put this values in the `Behavior Executor` component as in the image. | ||
- | ![variablewait_parameters_editor](https:// | + | ![variablewait_parameters_editor](images:bolt: |
Finally, add this new node to the Behavior Tree. | Finally, add this new node to the Behavior Tree. | ||
- | ![behavior_tree](https:// | + | ![behavior_tree](images:bolt: |
At this moment, the behavior should work properly. Nevertheless, | At this moment, the behavior should work properly. Nevertheless, | ||