public ExecutionResult IfChaseGotKid(BehaviourTreeInstance instance) { if (instance.HasToStart()) { Debug.Log("running after kid"); instance.WaitUntil(() => { // Here we are using Unity's implementation of asynchronous calls. // You will have to use a different one in different contexts. StartCoroutine(Chasing(instance)); }); } else if (instance.HasToComplete()) { bool b = Random.Range(0f, 1f) > 0.49; Debug.Log(instance.Actor.Name() + ": " + " got child: " + b); return(new ExecutionResult(b)); } else { Debug.Log("running after kid doing nothing"); } return(new ExecutionResult(true)); }
public ExecutionResult IfChaseGotKidCases(BehaviourTreeInstance instance) { if (instance.HasToStart()) { Debug.Log("running after kid"); instance.WaitUntil(() => { StartCoroutine(DoNap(instance)); }); } else if (instance.HasToComplete()) { var random = Random.Range(0f, 1f); var b = random > 0.6 ? 2 : (random > 0.3 ? 1 : 0); Debug.Log(instance.Actor.Name() + ": " + " got child: " + b); return(new ExecutionResult(b)); } else { Debug.Log("running after kid doing nothing"); } return(new ExecutionResult(true)); }