Differences

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

Link to this comparison view

Both sides previous revision Previous revision
quick:design [2020/09/03 09:31] pedroquick:design [2023/11/16 19:50] (current) – external edit 127.0.0.1
Line 161: Line 161:
  
 Conditions are nodes that, when reached, end immediately and inform their parent nodes whether they were evaluated as `true` or `false`. In behavior jargon, when a node returns `false` it is said to _fail_, and to _succeed_ if returns `true`. The distinctive feature of the internal composite nodes (`Sequence`'s and `Repeat' `s are the only ones we have used so far) is how they react to the values returned by their children conditions (if they _fail_ or _succeed_). Conditions are nodes that, when reached, end immediately and inform their parent nodes whether they were evaluated as `true` or `false`. In behavior jargon, when a node returns `false` it is said to _fail_, and to _succeed_ if returns `true`. The distinctive feature of the internal composite nodes (`Sequence`'s and `Repeat' `s are the only ones we have used so far) is how they react to the values returned by their children conditions (if they _fail_ or _succeed_).
- 
-<!-- 
-In a behavior, any node can prematurely end and _fail_. Imagine a situation where a buggy behavior asks an NPC to move to an unreachable area. In that case, the `MoveToPosition` action will not be able to locomete the game object to that position and just ends and _fails_. 
- 
-Ideally, behaviors should not be buggy and actions will never fail. Instead, this feature is used for _conditions_, that "sense" the environment and end with success or failure depending on that perception. 
- 
-Keep in mind that, from the behavior point of view, actions and conditions are _exactly the same_. But, when creating behaviors it is clarifying think about them as different concepts. Behavior Bricks uses in fact different colors for actions and conditions, and the Collection keeps them in different branches. As a rule of the thumb: 
- 
-- __Actions__: 
-    - Change the environment. 
-    - Usually last more than one game loop. 
-    - Hardly fail. 
-- __Conditions__: 
-    - Perceive the environment. 
-    - Usually last just one loop. 
-    - End with success or failure depending on the environment state. 
---> 
  
 In this section we will use the built-in `CheckMouseButton` condition that test if the user has just pressed one of the mouse buttons and ends with success in that case. In this section we will use the built-in `CheckMouseButton` condition that test if the user has just pressed one of the mouse buttons and ends with success in that case.