- Home /
parallax background jitter in 2d platformer
public class Parallax : MonoBehaviour
{
private float startPosX;
private float startPosY;
public Camera mainCamera;
public float parallaxEffectX;
public float parallaxEffectY;
// Start is called before the first frame update
void Start()
{
startPosX = transform.position.x;
startPosY = transform.position.y;
}
private void FixedUpdate()
{
float disX = (mainCamera.transform.position.x * parallaxEffectX);
float disY = (mainCamera.transform.position.y * parallaxEffectY);
//
//
transform.position = new Vector3(startPosX + disX, startPosY + disY, transform.position.z);
}
}
This is the Script i'm using for parallax effect for my 2d platformer, This script is added to different layers depending upon speed. My problem is while i'm testing the game on pc there is not jitter at all even when i'm using unity 5 remote to broadcast the game there isn't any noticeable jitters but when i'm building apk and testing it on mobile device the jitters is just unbearable. Please can someone help me out with this, Thanks in advance :)
Is there a reason you aren't using regular Update? FixedUpdate is usually just for aligning things to the physics updates.
Yeah, i just changed the code from update to fixedupdate. When Update is used the jitters start showing while on pc, as well on unity remote . :( don't know what's causing this.