Update vs FixedUpdate - Ruby2D and Jitter
Hi, I am new to unity and I am going through the Ruby project on Unity Learn. I've been following along with the but been noticing an issue with jitter in regards to moving both the bot and ruby.
I've taken a video which can be seen here: Link
The movement function for ruby is as follows
void Update() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); Vector2 position = rigidbody2d.position; position.x = position.x + speed * horizontal * Time.deltaTime; position.y = position.y + speed * vertical * Time.deltaTime; rigidbody2d.MovePosition(position); if (isInvincible) { invincibleTimer -= Time.deltaTime; if (invincibleTimer < 0) { isInvincible = false; } } }
A solution I found was changing the update method to the fixed update. Doing this I end up with much smoother input as can be seen here: Link
As I am new to unity I am unsure whether the solution is correct. While it seems to work am I just applying a band-aid to fix a more serious underlying issue? Or is the tutorial incorrect with regards to rigidbody movement? If it is incorrect why is it wrong to use motion in update() method?
Any help would be greatly appreciated!
Your answer
Follow this Question
Related Questions
Scene and game view in old project became completely black. 0 Answers
Animation not occuring instant,Survival Shooter Walking animation not instant... 0 Answers
Localization Unity Tutorial NullReferenceException 0 Answers
My player does not turn around 0 Answers
Unity3d rendermode change at runtime not correctly changed 0 Answers