예제 #1
0
    //Must use this since the animation is so short it cause the nav mesh
    // to continue moving almost immeditely
    public void doneAttacking()
    {
        GameObject      trav       = GameObject.FindGameObjectWithTag("Traveller");
        travellerHealth travHealth = trav.GetComponent <travellerHealth>();

        travHealth.TakeBasicDamage(10);
        attackSound.enabled = false;
        if (nav.isStopped)
        {
            nav.isStopped = false;
        }
    }
    //Must use this since the animation is so short it cause the nav mesh
    // to continue moving almost immeditely
    IEnumerator doneAttacking()
    {
        //have to wait for next frame to cheack
        // yield return new WaitForSeconds(0.4f);
        //wait until the apex of the animation's swing
        yield return(new WaitForSeconds(1.0672f));

        //Debug.Log("done");
        GameObject trav = GameObject.FindGameObjectWithTag("Traveller");

        if (trav == null)
        {
            Debug.Log("Could not find trav");
        }
        travellerHealth travHealth = trav.GetComponent <travellerHealth>();

        if (travHealth == null)
        {
            Debug.Log("Could not find health sciprt");
        }
        Animator travAnim = travHealth.getTravellerAnimator();

        if (travAnim == null)
        {
            Debug.Log("Could not find the traveller animator");
        }
        if (!attackInterrupt && !isStunned)   //may have been stunned a few frames before, not interrupted but code raced past, still stunned
        {
            travAnim.SetTrigger("isAttacked");
            travHealth.TakeBasicDamage(35);
            attackSound.enabled = false;
        }
        if (nav.isStopped)
        {
            nav.isStopped = false;
        }

        //    return;

        attackInterrupt = false;
        //yield return null;
    }