News Forums RAIN General Discussion and Troubleshooting Restart the Behavior Tree

This topic contains 5 replies, has 5 voices, and was last updated by  Sigil 1 year, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4919

    Pax
    Participant

    I’m currently working on a respawn mechanism that requires the AI to start over. And I was wondering if there were any way to restart a behavior tree or reset the ‘Patrol Route’ node, so that it starts form the first node again?

    • This topic was modified 2 years, 9 months ago by  Pax.
    • This topic was modified 2 years, 9 months ago by  Pax.
    #4924

    Aaron Mueller
    Participant

    Hello Pax,

    I believe that the RAIN.Core.AI.AIInit() method should allow you to reset your AI which should force the behavior tree to reload.

    That might be overkill, but I am afraid I don’t know enough about the Partol Route node and how to interact with the individual waypoints in the Waypoint Collection.

    Looking in the API docs, I found BasicNavigator.ReInit() Resets pathfinding and the current graph. Maybe that will do the trick?

    http://rivaltheory.com/community/api/

    Hope that helps.

    #4925

    prime
    Keymaster

    Hey @Pax - Do you want to start over from the first node arbitrarily, or do you just want the AI to go back to the start node after hitting the end of the patrol?

    If you want to start from the end of the patrol, just switch the Loop Type on your BT node to Loop instead of Ping Pong.

    If you actually want to reset the behavior tree and force it to reload, then follow Aaron’s advice, but call AIInit directly on the Mind, not on the AI.

    AI.Mind.AIInit();
    #4928

    Pax
    Participant

    Heya, thanks for the answers. I have to reload the whole tree at reset, so the AI.Mind.AIInit() was exactly what I was looking for.

    #37993

    alok@junesoftware
    Participant

    Hi @Prime
    AI.Mind.AIInit(); does restart the AI but doesn’t clear the runtime variables like Position Vectors etc in Working memory or doesn’t it and i am missing something.

    #38028

    Sigil
    Keymaster

    You are correct, AI.Mind.AIInit() will not reset the state of your memory. You could call AI.Memory.Clear() although that won’t maintain any memory variables you set in the editor before hand.

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

You must be logged in to reply to this topic.