コード例 #1
0
    //// Checks if character has touched the ground, if so, changes the animation to landing.
    public void CharacterIsGrounded()
    {
        BoxCollider2D boxCollider     = currentCharacter.GetComponent <BoxCollider2D>();
        float         extraHeightText = 1.0f;

        ///Check if character collider is touching another collider
        if ((Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0f, Vector2.down, extraHeightText, groundLayerMask).collider) != null)
        {
            characterSoundEffect.PlayCharacterSoundEffect("Landing");
            currentCharacter.EndAnimation(AnimationStates.LANDING);
        }
    }