- Home /
2D sprites flickering when moved at high speed
Hello, I am developing a 2D side scroll game in which player runs from left to right of the screen. I move the camera along with the player using the following code in Update function:
Vector3 targetPos = new Vector3(target.position.x - xPosDiff,myTransform.position.y,myTransform.position.z);
myTransform.position = targetPos;
where target is player, myTrasnform is transform of the Camera and xPosDiff is the position difference in x axis b/w player and camera (calculated in Start method).
Player is moved with rigidbody2D.velocity. However, at high speeds, ground and obstacle textures coming from right to left of screen seem to flicker.
How to fix this problem?
Thank you.
Is the camera getting following the position of the target in LateUpdate()?
If not, try that.
Tried LateUpdate, its still following the player properly but flickering is still there.
Change Update to FixedUpdate especially if you have a smoothed follow camera