News Forums RAIN General Discussion and Troubleshooting Pause execution of behavior tree

This topic contains 8 replies, has 2 voices, and was last updated by  prime 2 months, 2 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #34791

    jahshuwuh
    Participant

    I have a model with a behavior tree attached to it that’s a basic waypointpatrol. I need for the model to not begin that behavior tree until a certain event occurs. How would I go about stopping this behavior tree from executing on start up, and then starting it when my particular event occurs?

    #34792

    prime
    Keymaster

    A simple approach would be to do this:

    SELECTOR:
    — EVALUATE EXPRESSION (event hasn’t happened)
    — SEQUENCER
    — — EVERYTHING ELSE

    #34793

    jahshuwuh
    Participant

    I’m not sure I can specify this particular event within the behavior tree. It’s an augmented reality shooter game and I need it to wait until I have the tracking image in view before starting the behavior tree. So I have a C# file that’s overriding a method that checks if a tracking image has been seen by the camera. This is where I would need to place some logic to start up the behavior tree, if that’s possible.

    #34794

    prime
    Keymaster

    Other options then:

    1) Just set your AI to inactive until it is ready to go.

    AIRig tRig = gameObject.GetComponentInChildren<AIRig>();
    tRig.AI.IsActive = true;

    2) Stick with the Selector, but use your script to indicate whether you are ready to go.

    AIRig tRig = gameObject.GetComponentInChildren<AIRig>();
    tRig.AI.WorkingMemory.SetItem<bool>("ready", true);

    3) Activate/Deactivate the entire character game object using Unity methods.

    #34797

    jahshuwuh
    Participant

    Thanks for the reply. With option #1 using my own script I’m getting the error: “Cannot implicitly convert type ‘RAIN.Core.AIRig[]’ to ‘RAIN.Core.AIRig'” on this line:

    AIRig tRig = gameObject.GetComponentInChildren<AIRig>();

    So I need to store the return from gameObject.GetComponentInChildren<AIRig>() in an array then?

    #34799

    prime
    Keymaster

    Did you accidentally use GetComponentsInChildren?

    #34800

    jahshuwuh
    Participant

    Good call, didn’t notice that.

    #34801

    jahshuwuh
    Participant

    Should I then be setting the AI inactive in the Start() method and then can I set it back to active in the Update() method once a condition is reached? So far I can get it inactive with this method, but no luck in turning it back on.

    #34808

    prime
    Keymaster

    Yes, you should be able to simply toggle IsActive true or false to get what you want. IsActive shouldn’t impact initialization of the AI, just the running behavior.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.