Skip to content

Commit 2f11c1f

Browse files
committed
Document pause and suspend and close #64
1 parent 503a2dc commit 2f11c1f

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

Doc/QuickStart-Unity.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ Status expressions are invoked *frequently*; below, status expresssions are used
4949

5050
```cs
5151
using UnityEngine;
52-
// Typical AL imports
53-
using Active.Core; // Core API.
54-
using static Active.Core.status; // Static import for 'done()'
55-
// instead of 'status.done()', and
56-
// so forth.
52+
using Active.Core;
53+
using static Active.Raw;
5754

5855
public class Soldier : MonoBehaviour{
5956

@@ -83,7 +80,7 @@ public class Soldier : UGig{ // or `Gig`
8380
}
8481
```
8582

86-
When assigning or returning a status, use `done()`, `fail()` or `cont()`:
83+
When assigning or returning a status, use `done`, `fail` or `cont`:
8784

8885
```cs
8986
status Attack() => hasWeapon ? fail : Play("Strike");
@@ -293,6 +290,26 @@ In the above example, `UGig` is used since neither decorators, nor any ordered c
293290

294291
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.
295292

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+
296313
## Logging and the Log-Tree
297314

298315
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

Comments
 (0)