So I have a 2D character that moves in the screen with GetAxisRaw function and i’m for testing purposes relying on the update() method to move the char itself. Many 2D games have somesort of script that I tried to recreate that moves the various layers of the background at different speed, recreating thus a cool 3d looking environment while player moves.
Apparently I got how to move different background layers at different speed and all of this works except for the immense stuttering that I see at higher movement speed. PS: I see stuttering ONLY when the character moves and the background does it too
void Update ()
{
//Character Movement
GetAxis = Input.GetAxisRaw("Horizontal");
rigidbody2D.velocity = new Vector2(GetAxis * Velocity, rigidbody2D.velocity.y);
//if scrollbackground's set to true the following gets executed
if (ScrollBackground)
{
Background.transform.position = new Vector3(Background.transform.position.x + GetAxis * Velocity / 100, Background.transform.position.y, 5f);
}
}
feel free to ask for more details if the above seems right to you
IMPORTANT EDIT : this only happens if character movement is done trought rigidbody.velocity, if I move the char directly with transform.position, the stuttering doesn’t happen.