C# 2D InfiniteRunner run with same speed even when going up

I’m making a InfiniteRunner that you have to jump over obstacles and stuff. Sometimes there is a jump on the way. Thats where the problem starts.

Okay so what I’m trying to do is when my maincharacter goes forward on the jump that it keeps its speed, so it doesn’t slow down.
But because of the gravity or something it isn’t, it goes half way then it falls back down.

How can I fix this? Turning off the gravity isn’t a very good option because the maincharacter won’t find the floor ever again if it jumps.

Maybe there’s a way that the force is always constant?

You can try this.
It’s not so performance wise, but will do the trick.
The player will always be at 20 velocity on the X, and the Y will change accordingly to the jump.

private float acceleration = 20f;
private Vector2 jumpForce = new Vector2(0,10);

    void Update(){
       rigidbody2D.velocity = new Vector2(acceleration, rigidbody2D.velocity.y);
    void Jump(){

i can’t test it right now, but i think it will work :slight_smile: