After growing tired of stacking a half-dozen decorators around a Timeout, I decided it was time to make a TimeIN decorator. The functionality I wanted was a short delay timer from when the player enters the view of my monster, to when the monster actually detects them. But I ended up using it in a couple other places already. The key problem with reversing a Timeout’s status, is that I also needed the branch to be interrupted and return Failure if the child node ever fails. Timeout only returns one status. The image below shows the length I had to go to to get that functionality.
Before:
After:
My decorator will return Running if the child node returns Success or Running. If the child fails, it returns Failure. If the timein period is reached, and the child is still returning Success or Running, it will return Success.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
usingNodeCanvas.Framework;
usingParadoxNotion.Design;
usingUnityEngine;
namespaceNodeCanvas.BehaviourTrees
{
[Category("Decorators")]
[Description("Returns Success if the child node is still returning Success or Running after the timein period")]