public bool CheckGrounded()
    {
        if (PlayerManager.currentState == PlayerManager.PlayerState.Attacking)
        {
            return(true);
        }

        RaycastHit hit;

        if (Physics.Raycast(feetLevel.position, -Vector3.up, out hit, 0.1f))
        {
            timeSinceGrounded = Time.time;
            anim.SetBool("isGrounded", true);
            // anim.applyRootMotion = true;
            PlatformParent.ParentToPlatform(hit.transform, transform);

            grounded = true;

            return(true);
        }
        else
        {
            if (PlayerManager.currentState != PlayerManager.PlayerState.FreeClimbing)
            {
                anim.SetBool("isGrounded", false);
            }

            PlatformParent.RemoveParent(transform);

            // anim.applyRootMotion = false;

            grounded = false;

            return(false);
        }
    }
Example #2
0
 private void Awake()
 {
     Rigidbody = GetComponent <Rigidbody2D>();
     sprite    = GetComponent <SpriteRenderer>();
     Parent    = GetComponentInParent <PlatformParent>();
 }