You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Doc/QuickStart-Unity.md
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,11 +49,8 @@ Status expressions are invoked *frequently*; below, status expresssions are used
49
49
50
50
```cs
51
51
usingUnityEngine;
52
-
// Typical AL imports
53
-
usingActive.Core; // Core API.
54
-
usingstaticActive.Core.status; // Static import for 'done()'
55
-
// instead of 'status.done()', and
56
-
// so forth.
52
+
usingActive.Core;
53
+
usingstaticActive.Raw;
57
54
58
55
publicclassSoldier : MonoBehaviour{
59
56
@@ -83,7 +80,7 @@ public class Soldier : UGig{ // or `Gig`
83
80
}
84
81
```
85
82
86
-
When assigning or returning a status, use `done()`, `fail()` or `cont()`:
83
+
When assigning or returning a status, use `done`, `fail` or `cont`:
87
84
88
85
```cs
89
86
statusAttack() =>hasWeapon?fail:Play("Strike");
@@ -293,6 +290,26 @@ In the above example, `UGig` is used since neither decorators, nor any ordered c
293
290
294
291
The above example also suggests how you compose versatile agents by assembling ever larger BTs, combining OOP's delegation pattern with BT's modular control paradigm.
295
292
293
+
### Pause, Suspend and Resume
294
+
295
+
When using the stateless API (such as with Active-LT) you do not have access to the `Wait` and `After` decorators. However you can still make your BT sleep/wait:
296
+
297
+
```cs
298
+
// Inside any Stepper, including UGig and UTask
299
+
Pause(3.5f); // Pause and resume after 3.5 seconds (game time)
300
+
Suspend(); // Pause indefinitely
301
+
Resume(); // Resume after calling `Pause` or `Suspend`
302
+
```
303
+
304
+
There is a key difference between `Pause` and `Wait`.
305
+
306
+
-`Wait` is waiting on a specific subtask. For example you may insert a delay after delivering a blow. However if your BT navigates to another task, this delay will then be ignored.
307
+
-`Pause` and `Suspend` disable running the behavior tree. In this case your BT will only resume after the delay has expired, or code external to the BT has invoked `Resume`.
308
+
309
+
`Pause` and `Suspend` may be easier to understand than `Wait` and `After`. In general though, `Wait` is appropriate when the agent delay further action 'on their own accord'.
310
+
311
+
TIP: *if neither `Pause` nor `Wait` do exactly what you want them to, redesign around what the agent are waiting* for *and write a task that will wait until the relevant state change has occured.*
312
+
296
313
## Logging and the Log-Tree
297
314
298
315
Active Logic's logging features are helpful, in that the behavior of complex agents is not transparent, and tracing loops running at 10~60Hz in the console is not practical.
0 commit comments