Jump too Teleporty

So I’m extremely new to unity and my character jump works, however, the actual jump is just teleporting upward. How would I make this a fluid up and down motion rather than teleporting up and falling down with gravity?
Thanks!

{
    public float speed;
    public Rigidbody2D rb;
    private float movement;
    public float jump;


   
    void Start()
    {
       
    }

  
    void Update()
    {
      

       
        if (Input.GetKeyDown(KeyCode.Space))
        {
           
            rb.AddForce(new Vector2(rb.velocity.x, jump));
        }
        {
            movement = Input.GetAxisRaw("Horizontal");

        }
       
        rb.velocity = new Vector2 (movement * speed, 0 * Time.deltaTime);   
    }
}

I guess you mean it looks like you rigibdbody just teleports some place in the air and the just starts falling right? I think the problem must be you’re passing too high values to AddForce. I say this because I see you’re passing rb.velocity.x in the X component, and that’s not really a comparable magnitude (unless you use the ForceMode.VelocityChange mode). You could try just setting the initial vertical jump speed. Something like:
rb.velocityY = jump;

Another problem I see here is you’re both adding a force and modifying velocity. In this line:
rb.velocity = new Vector2 (movement * speed, 0 * Time.deltaTime);
You’re setting rb.velocity.y to 0 in every frame (which doesn’t mean it will fully stop, because gravity will still move you down between frames). If you just want to move horizontally I suggest writting something like:
rb.velocityX = movement * speed

1 Like