- Home /
Jittery track movement
At present, I am working on 2d racing game. So that I have to move track as per game requirement. For that I have written following code.
public float speed;
void FixedUpdate ()
{
rigidbody2D.MovePosition (transform.position + (Vector3.up * speed * Time.deltaTime * -1f));
}
Using above code, track continuously move but with complete jerk. I can't able to understand where I have written wrong code. Please give some suggestion in this.
At present only car left/right movement and track movement code exist in game. Also I have notice that there is no FPS loss in game. I got around 70FPS in android device.
EDIT
rigidbody2D.velocity = Vector3.up * speed * -1f;
I have tried with this code also but didn't get any success.
you are using a Vector3 in a 2D game? try use a Vector2 just to see if that helps. tell me what it is that you are trying to do ins$$anonymous$$d of what you are doing please.
or put same code in LastUpdate() method ins$$anonymous$$d, dont put your code on the camera.
@DESI$$anonymous$$A, you suggestions not work for me. I have change track's rigidbody Interpolate mode to Interpolate from None. This change gives some what improvement in track movement but not as smooth that I looking for.
I need more info on what it is that you are trying to do. post a screenshot
Following image demonstrate screenshot of my game play screen. https://www.dropbox.com/s/qwu5e1jt4imlp26/Screenshot%202015-01-31%2023.01.04.png?dl=0 If you have time then we can directly chat for problem.
ahh. have you tried using transform.Translate in the Update function. I dont really understand why you use rigidbody on something that has nothing to do with physics, you are just moving i.e. translating the road to follow the car. So try transform.Translate ins$$anonymous$$d and use it in Update() ins$$anonymous$$d. the reason it jiggers is because FixedUpdate is not updated as frequently as Update() is
Your answer
![](https://koobas.hobune.stream/wayback/20220613182046im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Very jerky camera movement with rigidbody 1 Answer
character controller sinks into platform while using raycast to detect collision 0 Answers
How can you make a 2D object move based on rotation, and rotate while moving? 1 Answer
How can I keep the Ground ALIGNED with the red line in the image below 1 Answer
Help with making a map based game! 3 Answers