- Home /
Problem of visual lag for moving pictures. How to make it smoother?
Hi.
I make a game in Unity3D (+2D ToolKit) for iOS.
It is 2d runner/platformer with side view. So on screen is moving background and obstacles. And we control up/down the main character to overcome obstacles.
The problem is that the moving picture has a visual lag. In other words, it moves jerkily or creates the tail area of the previous frames on iOS-devices. In XCode the number of frames is 30 and over.
I have objects 'plain' with the following script:
public class Move: Monobehavior
{
private float x;
public float Speed = 128.0f;
void Start()
{
x = transform.position.x;
}
void Update()
{
x += Time.DeltaTime *Speed;
Vector3 N = transform.position;
N.x = mathf.FloorInt(x);
transform.position = N;
}
}
The question is how to make the move of background smoother, without jerks and flicker on screen while playing? Maybe the problem is in framerate parameter. Can anybody help me to find a solution?
I also tried:
public class $$anonymous$$ove: $$anonymous$$onobehavior
{
private Vector3 P;
public float Speed = 128.0f;
void Start()
{
P = transform.position;
}
void FixedUpdate() {
P.x += Time.fixeDeltaTime * Speed;
transform.position = P;
}
}
Did it fixed and with decreased 'fixedDeltaTime' from default 0.02 to 0.01. As a result - the same jerks, but just for smaller intervals...