Exemple #1
0
    //---------------------------------------------------------------------------------- -
    //  Butt Stomp Function
    //---------------------------------------------------------------------------------- -
    private IEnumerator ButtStomp()
    {
        if (m_buttStompInitiated || m_buttStomping)
        {
            yield break;
        }

        m_buttStompInitiated = true;

        //  Set Controller Vibration  //
        SetControllerVibration(0.3f, 0.3f);

        //  Log the height  //
        m_buttStompStartHeight = transform.position.y;

        m_buttStompAttacker.EnableAttack();
        allowNegativeScaling = false;
        //m_freezeVelocity = true;

        m_audioPlayer.PlayOneShot(AudioLibrary.Get().buttStompSwoosh01);

        //  Play Animation  //
        m_animator.SetTrigger("ButtstompStart");
        m_animator.SetBool("ButtStomping", true);

        //  FREEZE  //
        float freezeTimer = 0.5f;

        while (freezeTimer > 0)
        {
            //  Set Velocity to zero  //
            Vector3 newVelocity = new Vector3(m_rigidbody.velocity.x * 0.95f, 0, 0);
            //m_rigidbody.velocity = Vector3.zero;
            m_rigidbody.velocity = newVelocity;

            //  Iterate Timer  //
            freezeTimer -= Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }

        //  Mark that we're in this action  //
        m_buttStomping = true;

        while (m_buttStomping)
        {
            //  Apply a downward force  //
            //m_rigidbody.velocity = new Vector3(m_rigidbody.velocity.x, buttStompForce, m_rigidbody.velocity.z);
            m_rigidbody.velocity = new Vector3(0, buttStompForce, 0);
            yield return(new WaitForEndOfFrame());
        }
    }