// Update is called once per frame void Update() { if (SceneManager.GetActiveScene().name == "Stage2" && count == 0) //스테이지2이면 트리 재시작 { Debug.Log("Start Tree2"); m_Sonny = gameObject.GetComponent <SonnyMove>(); root.AddChild(selector); selector.AddChild(seqDead); selector.AddChild(seqMovingAttack); moveinmap.Enemy = m_Sonny; m_OnAttack.Enemy = m_Sonny; isCollision.Enemy = m_Sonny; detectPos.Enemy = m_Sonny; m_IsDead.Enemy = m_Sonny; seqMovingAttack.AddChild(m_OnAttack); seqMovingAttack.AddChild(moveinmap); seqMovingAttack.AddChild(isCollision); seqMovingAttack.AddChild(detectPos); seqDead.AddChild(m_IsDead); behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); count++; } }
// Start is called before the first frame update void Start() { Debug.Log("Start Tree"); m_Sonny = gameObject.GetComponent <SonnyMove>(); root.AddChild(selector); selector.AddChild(seqDead); // seqDead 노드를 selector의 자식 노드로 연결 selector.AddChild(seqMovingAttack); // seqMovingAttack 노드를 selector의 자식 노드로 연결 moveinmap.Enemy = m_Sonny; // m_Enemy를 넣어 초기화시킴 m_OnAttack.Enemy = m_Sonny; isCollision.Enemy = m_Sonny; detectPos.Enemy = m_Sonny; m_IsDead.Enemy = m_Sonny; seqMovingAttack.AddChild(m_OnAttack); seqMovingAttack.AddChild(moveinmap); //seqMovingAttack 노드에 클래스 변수들을 자식으로 추가 seqMovingAttack.AddChild(isCollision); seqMovingAttack.AddChild(detectPos); seqDead.AddChild(m_IsDead); //seqDead 노드에 클래스 변수를 자식으로 추가 behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }