Пример #1
0
    void Update()
    {
        float absVelocityX = Mathf.Abs(m_rigidbody.velocity.x);
        float absVelocityY = Mathf.Abs(m_rigidbody.velocity.y);


        state = m_playerController.IsGrounded() ? SquashState.kRunning : SquashState.kAir;
        if (state == SquashState.kRunning && absVelocityX <= .01)
        {
            state = SquashState.kIdle;
        }

        if (state == SquashState.kAir)
        {
            float t            = Mathf.Min(absVelocityY, 10.0f) / 10.0f;
            float squashAmount = Mathf.Lerp(1, .9f, t);
            squashAmount         = m_rigidbody.velocity.y > 0 ? squashAmount : 1 / squashAmount;
            transform.localScale = new Vector3(squashAmount, 1 / squashAmount, 1);
        }
        else if (state == SquashState.kRunning)
        {
            float squashAmountX = 1.0f + Mathf.Cos(Time.time * 20.0f) * .1f;
            float squashAmountY = 1.0f - Mathf.Cos(Time.time * 20.0f) * .1f;
            transform.localScale = new Vector3(squashAmountX, squashAmountY, 1);
        }
        else if (state == SquashState.kIdle)
        {
            transform.localScale = new Vector3(1, 1, 1);
        }
    }
Пример #2
0
    public void SetState(SquashState state)
    {
        this.squashstate = state;
        switch (this.squashstate)
        {
        case SquashState.On:
            break;

        case SquashState.Off:
            break;
        }
    }