Ground check is acting weird i think.

weird bug, i can only jump using coyote time or buffer jumping please help , any suggestion is much apprecited.

private void Update()
    {
        // is the player grounded
        bool isGrounded = Physics2D.OverlapCircle(groundCheck.position, 0.1f, groundLayer);

        // check if touching wall
        isTouchingWall = Physics2D.OverlapCircle(wallCheck.position, 0.1f, wallLayer) || Physics2D.OverlapCircle(wallCheck2.position, 0.1f, wallLayer);

        // cyote time logic
        if (isGrounded)
        {
            cyoteTimeCounter = cyoteTime;
        }
        else
        {
            cyoteTimeCounter -= Time.deltaTime;
        }

        // jump logic
        if (Input.GetButtonDown("Jump"))
        {
            jumpBufferCounter = jumpBuffer;
        }
        else
        {
            jumpBufferCounter -= Time.deltaTime;
        }

        if (isGrounded && jumpBufferCounter > 0f && (cyoteTimeCounter > 0f || isTouchingWall))
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpForce);
            animator.SetBool("IsJumping", true);
            jumpBufferCounter = 0;
            dust.Play();

            if (isTouchingWall)
            {
                rb.velocity = new Vector2(-transform.localScale.x * moveSpeed, rb.velocity.y);
            }
        }

        if (Input.GetButtonUp("Jump") && rb.velocity.y > 1f)
        {
            rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.75f);
            animator.SetBool("IsJumping", true);
            dust.Play();

            cyoteTimeCounter = 0f;
        }

        // flipping the player if looking left
        float moveDirection = Input.GetAxis("Horizontal");


        // telling the animator that the player is grounded
        if (isGrounded && rb.velocity.y < 0.01f)
        {
            animator.SetBool("IsJumping", false);
        }
}

Drop a breakpoint, it will be faster and no one wants to dissect 100 lines of code.

I checked the code briefly before you removed most of it and I didn’t see you checking isGrounded when you were checking if a jump were possible aside from the logic involving cyoteTime.

sorry man

Nah, all good, honestly I’d drop a breakpoint still, it’s the best for these types of conditionals.

Also are you familiar with states?

You may want to see if states would be better in your case

rontian/MonsterLove.StateMachine (github.com)

(GPT prompt as an example):

public enum CharacterState
{
    Grounded,
    Jumping,
    WallSliding,
    Sliding
}

public class CharacterController : MonoBehaviour
{
    public CharacterState currentState;

    void Update()
    {
        // Update the character's behavior based on its current state
        switch (currentState)
        {
            case CharacterState.Grounded:
                // Handle grounded behavior
                break;
            case CharacterState.Jumping:
                // Handle jumping behavior
                break;
            case CharacterState.WallSliding:
                // Handle wall sliding behavior
                break;
            case CharacterState.Sliding:
                // Handle sliding behavior
                break;
            default:
                break;
        }
    }

    // Method to transition to a new state
    void TransitionToState(CharacterState newState)
    {
        currentState = newState;
    }

    // Example method to perform a jump
    void Jump()
    {
        // Check if the character is grounded or wall sliding before allowing a jump
        if (currentState == CharacterState.Grounded || currentState == CharacterState.WallSliding)
        {
            // Perform the jump action
            TransitionToState(CharacterState.Jumping);
            // Apply jump force, etc.
        }
    }

    // Example method to perform wall slide
    void WallSlide()
    {
        // Check if the character is touching a wall and not grounded
        if (/* Condition to check if character is touching a wall */)
        {
            TransitionToState(CharacterState.WallSliding);
            // Apply wall slide force, etc.
        }
    }

    // Example method to perform slide
    void Slide()
    {
        // Check if the character is grounded and moving with sufficient speed
        if (/* Condition to check if character is grounded and moving with sufficient speed */)
        {
            TransitionToState(CharacterState.Sliding);
            // Apply slide force, etc.
        }
    }
}

hey man didnt realize i had chopped off half the jumping script thank you for telling me if you could tell me where i would need to put that IsGrounded check that would be great

nah never used states,im pretty new to game dev

I’d personally take some time to learn about them for this case, it’s a perfect example and it’s used all the time for many different things when used properly.