|
1 | 1 | # fluid-behavior-tree
|
2 | 2 |
|
3 |
| -@TODO Make sure copy / paste examples work correctly (custom node tutorial, quick start snippet). |
| 3 | +@TODO Make sure copy / paste examples work correctly (custom node tutorial, splicing, quick start snippet). |
4 | 4 |
|
5 | 5 | A pure code behavior tree micro-framework built for Unity3D projects.
|
6 | 6 | Granting developers the power to dictate their GUI presentation.
|
@@ -382,6 +382,51 @@ public class TreeBuilderCustom : BehaviorTreeBuilderBase<TreeBuilderCustom> {
|
382 | 382 |
|
383 | 383 | ### Custom Conditions
|
384 | 384 |
|
| 385 | +Custom condition example template. |
| 386 | + |
| 387 | +```C# |
| 388 | +using UnityEngine; |
| 389 | +using Adnc.FluidBT.Tasks; |
| 390 | + |
| 391 | +public class CustomCondition : ConditionBase { |
| 392 | + // Triggers only the first time this node is run (great for caching data) |
| 393 | + protected override void OnInit () { |
| 394 | + } |
| 395 | + |
| 396 | + // Triggers every time this node starts running. Does not trigger if TaskStatus.Continue was last returned by this node |
| 397 | + protected override void OnStart () { |
| 398 | + } |
| 399 | + |
| 400 | + // Triggers every time `Tick()` is called on the tree and this node is run |
| 401 | + protected override bool OnUpdate () { |
| 402 | + // Points to the GameObject of whoever owns the Behavior Tree |
| 403 | + Debug.Log(Owner.name); |
| 404 | + return true; |
| 405 | + } |
| 406 | + |
| 407 | + // Triggers whenever this node exits after running |
| 408 | + protected override void OnExit () { |
| 409 | + } |
| 410 | +} |
| 411 | +``` |
| 412 | + |
| 413 | +Code required to modify your tree builder. |
| 414 | + |
| 415 | +```C# |
| 416 | +using Adnc.FluidBT.Trees; |
| 417 | + |
| 418 | +public class TreeBuilderCustom : BehaviorTreeBuilderBase<TreeBuilderCustom> { |
| 419 | + ... |
| 420 | + public TreeBuilderCustom CustomCondition (string name) { |
| 421 | + _tree.AddNode(Pointer, new CustomCondition { |
| 422 | + Name = name |
| 423 | + }); |
| 424 | + |
| 425 | + return this; |
| 426 | + } |
| 427 | +} |
| 428 | +``` |
| 429 | + |
385 | 430 | ### Custom Composites
|
386 | 431 |
|
387 | 432 | ### Custom Decorators
|
|
0 commit comments