W
W
WasTabon2021-03-02 17:34:50
Unity
WasTabon, 2021-03-02 17:34:50

Why does the character move jerkily?

public GameObject player;
    public GameObject createObj;
    public Rigidbody2D rigidbody2D;
    public float speed = 10f;

    private void Start() 
    {
        rigidbody2D = player.GetComponent<Rigidbody2D>();
    }

    private void Update() 
    {
        rigidbody2D.velocity = new Vector2(1 * speed, rigidbody2D.velocity.y);
    }
}


For some reason it jerks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bruh_Bruh, 2021-03-02
@WasTabon

Something tells me that you forgot about Time.deltaTime. Just write:

private void Update() 
    {
        rigidbody2D.velocity = new Vector2(1 * speed * Time.deltaTime, rigidbody2D.velocity.y);
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question