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
  • #4919


    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.

    Aaron Mueller

    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?

    Hope that helps.



    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.



    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.



    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.



    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.