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:program [2018/05/18 21:27] – pedro | quick:program [2020/09/03 09:16] – pedro | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
# Programmers Quick Start Guide | # Programmers Quick Start Guide | ||
Line 16: | Line 17: | ||
- | {{ : | + |  that should be available as action parameters in the editor _must have_ an `InParam` attribute, specifying the visible name. This allows you both to use even private attributes as editor parameters, and to specify editor names with characters that would be invalid for a C# identifier (such as spaces). Optionally, when the attribute has a basic type, a default value can also be set. | + | - The class attributes (or properties) that should be available as action parameters in the editor _must have_ an `InParam` attribute, specifying the visible name. This allows you both to use even private attributes as editor parameters, and to specify editor names with characters that would be invalid for a C# identifier (such as spaces). Optionally, when the attribute has a basic type, a default value can also be set. `Setting a default value by code does not work in some Unity versions, so maybe you will have to set the value in the editor`. |
Please note the name difference between the Behavior Bricks `OnUpdate()` method and the common `MonoBehavior:: | Please note the name difference between the Behavior Bricks `OnUpdate()` method and the common `MonoBehavior:: | ||
Line 104: | Line 105: | ||
- Create a new node in the canvas for the `ShootOnce` action. Note the action parameters in the inspector and, specifically, | - Create a new node in the canvas for the `ShootOnce` action. Note the action parameters in the inspector and, specifically, | ||
- | {{ : | + | . | - Connect the priority selector and the `ShootOnce` action so that shooting is the first child to be considered (higher priority). | ||
- Right click on the default guard `AlwaysTrue` of the `ShootOnce` node, select `Replace with ...` and choose `Perception/ | - Right click on the default guard `AlwaysTrue` of the `ShootOnce` node, select `Replace with ...` and choose `Perception/ | ||
- | {{ : | + | ` method to monitor its state. That will happen with higher priority conditions that are currently false, or with the first condition that is currently true. In our example, imagine the light is on (it is daytime), and the enemy is near enough to the player, so it is shooting at him. The state is summarized in the figure, where the `Shoot` action is highlighted as the current action. | But when a condition is used in a priority selector or a guard decorator, something unpleasant occurs: the execution engine could need to continually call to its `Check()` method to monitor its state. That will happen with higher priority conditions that are currently false, or with the first condition that is currently true. In our example, imagine the light is on (it is daytime), and the enemy is near enough to the player, so it is shooting at him. The state is summarized in the figure, where the `Shoot` action is highlighted as the current action. | ||
- | {{ : | + |  _and_ the player is still near enough to be shot (`B` condition is still true). As far as we currently know, that requires the execution engine to invoke `Check()` in both conditions. In general, if a priority selector is executing its n-th child, then _n_ conditions must be checked. When night has fallen, our `SleepForever` does not require CPU at all; but the `IsNightCondition` is checked every frame in order to know if the sleeping `SleepForever` should be still used. | In this situation, the execution state must guarantee _each cycle_ that the night has not yet fallen (`A` condition is still false) _and_ the player is still near enough to be shot (`B` condition is still true). As far as we currently know, that requires the execution engine to invoke `Check()` in both conditions. In general, if a priority selector is executing its n-th child, then _n_ conditions must be checked. When night has fallen, our `SleepForever` does not require CPU at all; but the `IsNightCondition` is checked every frame in order to know if the sleeping `SleepForever` should be still used. | ||
Line 485: | Line 486: | ||
- | | + | Now, any object can receive notifications from the light using: |
<code csharp> | <code csharp> | ||
Line 730: | Line 731: | ||
--> | --> | ||
+ | |||
+ | </ |