Beispiel #1
0
    public override void Execute(CompanionBehaviorTree MainBT)
    {
        GameObject companionModel = GameObject.FindGameObjectWithTag("Companion");

        companion = companionModel.GetComponent <CompanionBehaviorTree>();

        companionAnim = companion.anim;


        Player       = MainBT.Player;
        curCondition = Condition.RUNNING;
        //The LookAt Function is currently running
        if (companion.StopFollow == false)
        {
            MainBT.transform.LookAt(Player);
            MainBT.transform.position += MainBT.transform.forward * CompanionSpeed * Time.deltaTime;

            if (Vector3.Distance(Player.position, MainBT.transform.position) < 1.5)
            {
                companionAnim.SetTrigger("Idle");
                curCondition   = Condition.SUCCESS;
                CompanionSpeed = 0;
                //Companion has reached the player
            }
            else
            {
                companionAnim.SetTrigger("Walk");
                curCondition   = Condition.FAIL;
                CompanionSpeed = 5;
                //Companion is far and needs to walk to the player
            }
        }
    }
Beispiel #2
0
    public override void Execute(CompanionBehaviorTree MainBT)
    {
        for (int i = 0; i < Children.Count; i++)
        {
            Children[i].Execute(MainBT);


            //If Node is Fail
            if (Children[i].curCondition == Condition.FAIL)
            {
                curCondition = Condition.FAIL;
                return;
            }

            //If Node is Running
            if (Children[i].curCondition == Condition.RUNNING)
            {
                curCondition = Condition.RUNNING;
                return;
            }
        }

        //If Node is Success
        curCondition = Condition.SUCCESS;
        return;
    }
Beispiel #3
0
    public override void Execute(CompanionBehaviorTree MainBT)
    {
        GameObject comp           = GameObject.FindGameObjectWithTag("Companion");
        GameObject companionModel = GameObject.FindGameObjectWithTag("Companion");

        companion = companionModel.GetComponent <CompanionBehaviorTree>();

        IntendedDis = 1;



        //if there is at least one object with the layer in the range
        if (companion.ObjImp != null)
        {
            curCondition = Condition.RUNNING;
            Debug.Log("RUNNING");
            companion.StopFollow = true;
            float Step = speed * Time.deltaTime;
            comp.transform.position = Vector3.MoveTowards(comp.transform.position, companion.ObjImp.transform.position, Step);
        }
        if (companion.ObjImp != null)
        {
            if (Vector3.Distance(comp.transform.position, companion.ObjImp.transform.position) <= IntendedDis)
            {
                curCondition         = Condition.SUCCESS;
                companion.StopFollow = false;
                Debug.Log("SUCCESS");
            }
        }

        if (companion.ObjImp = null)
        {
            curCondition         = Condition.FAIL;
            companion.StopFollow = false;
            Debug.Log("FAIL");
        }
    }
Beispiel #4
0
 public virtual void Execute(CompanionBehaviorTree MainBT)
 {
     Debug.Log("State is Ready");
 }