News Forums RAIN General Discussion and Troubleshooting Reset Behavior tree when respawned

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #40375

    christougher
    Participant

    Hi I use a pooling system for my enemies and I’ve noticed that when one is respawned the behavior tree is in the same state as when it was destroyed creating some wonky behavior. Boo wonkiness. Is there an easy way to reset the behavior tree when de/respawned? I’ve tried toggling the ai component off and on, and disabling the AI GO altogether and none of that seems to reset the bx tree.

    #40377

    ck
    Participant

    AIRig.AI.Mind.AIInit() will reset your behavior tree state, however it’ll also tank your game’s framerate on mobile by Deserializing/Serializing all the AI data (or whatever it is that it does behind scenes).

    #40387

    christougher
    Participant

    Thanks, I appreciate the help!

    Here’s my simple code if it helps anyone…

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using RAIN.Action;
    using RAIN.Core;
    [RAINAction]
    public class ClearAI : MonoBehaviour
    {
    public AIRig aiRig;
    	void OnDisable()
        {
            aiRig.AI.Mind.AIInit(); 
        }
    }
    • This reply was modified 2 months, 4 weeks ago by  christougher.
    • This reply was modified 2 months, 4 weeks ago by  christougher.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.