Jumping with Rigidbody.AddForce not working?

I sort of have two questions here. I’m trying to move my 2D player using velocity instead of transform.position, and so I switched my old one-line movement code to this:

rb.velocity = new Vector3(Input.GetAxis("Horizontal"), 0, 0) * moveSpeed * Time.deltaTime;

When I did this, suddenly my old jump script using Ridgidbody.AddForce went from being a smooth jump to sort of teleporting the player up into the air.

rb.AddForce(transform.up * jumpForce, ForceMode2D.Impulse);

I think it has something to do with the the y value I’m setting to 0 constantly in the first line, but any help would be appreciated.

Well that is one reason why i do not like setting velocity values directly.

You should be able to solve your issue if you change your velocity stuff to:

 rb.velocity = new Vector3(Input.GetAxis("Horizontal")* moveSpeed * Time.deltaTime, rb.velocity.y, 0) ;

Hi,
I am trying to implement jump action on key pressed; I do the following:

rb.linearVelocity= new Vector3(Input.GetAxis("Horizontal")* moving * Time.deltaTime, rb.linearVelocity.y * jumping , 0) ;

I use jumping as variable to set properly the jump force… the problem is that despite I set several values the jump always reach short distance