- Home /
Velocity is not matching the Vector3 it is assigned
Hello, everyone! I've had this problem with a 2D object (the player) that is supposed to move left and right. Every time I move it over a long distance, I can't help but notice the object jiggle every so and often. After looking further into my code, I've discovered that the "movement" Vector is not matching the Velocity:
float horizontal = Input.GetAxis("Horizontal");
Vector3 movement = new Vector3(horizontal * speed, rb.velocity.y, 0f);
rb.velocity = movement;
The "movement" vector is (7, 0, 0) while the velocity vector varies between (5, 0, 0) and (6.7, 0, 0) at maximum.
What am I doing wrong? Is this the cause of the "jiggling"? I appreciate all the answers!
Answer by vJoeyz · Dec 19, 2018 at 10:05 AM
The decreased velocity vector is probably due to drag. To fix the jittery movement, try setting the Rigidbody's interpolation mode to interpolation
.
Your answer
Follow this Question
Related Questions
How do I stop momentum in 2D sidescroller? 1 Answer
How can I add an impulse force on top of my walking force? 1 Answer
How to Apply Animations to Script 1 Answer
Why Rigidbody 2d doesnt stop sliding? 2 Answers
Moving tram along rail. 0 Answers