#Jumping problem 2

1 messages · Page 1 of 1 (latest)

dull wind
#

@green scarab

#

yes I can

green scarab
#

Well I can say that the jump count never gets reset, does ```cs

if(isGrounded && velocity.y < 0)
{
velocity.y = -2f;
jumpCount = 0f;
}

dull wind
#

no it doesnt

#

because this doesnt work ```csharp
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.normal.y > 0.1)
{
isGrounded = true;
Debug.Log("Grounded");
}
else
{
isGrounded = false;
Debug.Log("Not Grounded");
}
if(hit.gameObject.CompareTag("WallJump") && !isGrounded)
{
fallingGravity = 1f;
velocity.y = -1f;
jumpCount = 1f;
Debug.DrawRay(hit.point, hit.normal, Color.red, 1.25f);
}
}

#

I used pc.isGrounded

#

before

green scarab
#

Also double check that the Debug.Log() statements that are displaying wether or not you are grounded display at the correct times

dull wind
#

But its kinda buggy

green scarab
#

Like when you are grounded does the “Grounded” display

#

And vice versa

#

if(hit.normal.y > 0.1)
        {
            isGrounded = true;
            Debug.Log("Grounded");
        } 
        else 
        {
            isGrounded = false;
            Debug.Log("Not Grounded");
        }

Does this work correctly

dull wind
#

but when I jump

#

it still says grounded

#

but when I touch a wall jumpable wall

#

WAIT

#

I think I know why

#

how do I check if the player is not touching anything?

green scarab
#

Ur always above 0.1

dull wind
#

I dont understand how hit.normal.y works

green scarab
#

If you are jumping, your y is going up

#

You are checking if its > 0.1

#

It always will be

#

Oh

#

Its hit.normal

dull wind
#

wait what?

dull wind
green scarab
#

Try logging the hit.normal.y values in update

#

See what comes up

dull wind
#

when I first load in it says one

#

but when I touch a wall

#

it gives me a random number like

green scarab
#

Woah

#

Thats about 0.0000000238