make rigidbody jump and maintain velocity

I know people have previously asked this but i just cant find an answer that works for me. I want my character to be able to be moving and have a smooth up and down jump how would i script this??

Is this a 2d platformer kind of sense or a 3d platformer? Either way it’s kind of the same. Just have gravity turned on and it’ll do the work for you.

Transform trans;
float jumpVelocity;

void Jump ()
{
    trans.velocity += new Vector3(0.0f, jumpVelocity, 0.0f);
}

Now, if you have gravity turned off… you’re gonna have a harder time. We’ll have to apply a downwards acceleration, however depending on what type of game you are making, that’ll vary a lot in how we do it. If my above example doesn’t work for you, just tell me why, and a bit mopre information on the layout of the game (2d/3d, physics/no physics, planar movements/platformer, etc)