Esempio n. 1
0
    private void FixedUpdate()
    {
        if (mStunLeft > 0f && mStunLeft - Time.fixedDeltaTime < 0f)
        {
            animController.SetShocked(false);
        }
        mStunLeft -= Time.fixedDeltaTime;

        bool wasGrounded = m_Grounded;

        m_Grounded = false;

        // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground
        // This can be done using layers instead but Sample Assets will not overwrite your project settings.
        Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);
        for (int i = 0; i < colliders.Length; i++)
        {
            if (colliders[i].gameObject != gameObject)
            {
                m_Grounded = true;
                if (!wasGrounded)
                {
                    OnLandEvent.Invoke();
                    animController.Land();
                    LandSound.Play();
                }
            }
        }
    }