Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (myVitals.getCurHealth() > 0)
        {
            switch (state)
            {
            case ai_states.idle:
                stateIdle();
                break;

            case ai_states.moveToCover:
                stateMoveToCover();
                break;

            case ai_states.combat:
                stateCombat();
                break;

            case ai_states.investigate:
                stateInvestigate();
                break;

            default:
                break;
            }
        }
        else
        {
            anim.SetBool("move", false);

            //to be able to investigate last known position of dead soldiers, we'll need to implement dead, instead of destroying the soldier gameobject
            if (GetComponent <BoxCollider>() != null)
            {
                Destroy(GetComponent <BoxCollider>());
            }

            if (currentCover != null)
            {
                coverManager.ExitCover(currentCover);
            }

            Quaternion deathRotation = Quaternion.Euler(90, myTransform.rotation.eulerAngles.y, myTransform.rotation.eulerAngles.z);
            if (myTransform.rotation != deathRotation)
            {
                myTransform.rotation = deathRotation; //maybe it will work?
            }
        }
    }