Getting rigidbody to jump by changing the velocity

Hello, I’m trying to get my character to jump by changing the velocity along the y axis. I’m making a simple snowboard/skiing game so the character slides down a hill and the velocity keeps going down as well. I’m able to get him to jump a little when he’s going slow down the hill, then as he speeds up he jumps higher and higher. And then when he’s going up hill, he seems to want to jump down instead of up. How do I fix this so that he jumps the same amount regardless of how fast he’s going or if he’s going up or downhill. Thanks

if (Input.GetButtonDown ("Jump")) 
{
    rigidbody.velocity.y = 2;
}

So firstly he’s already got a Y velocity that you are just overwriting :slight_smile: Hence the weirdness…

You could add something to his velocity:

 rigidbody.velocity = rigidbody.velocity + Vector3.up * 2;

Or you are probably better adding a force:

 rigidbody.AddForce(0,10,0);

Bear in mind that rigidbodies are simulated in World space - for instance adding to the Y on an inverted character will not move it towards the head, but the feet - not that this is probably your issue right now, just for reference. If you want to simulate force in the character’s coordinates it’s rigidbody.AddRelativeForce(0,10,0)

I take player collider with enemy when using UNET. but not working.