- Home /
Question by
MonkizakiTheGOD · Feb 08, 2020 at 11:19 AM ·
delayendless runnerparallaxbackgrounds
Im confused,Background parallaxing looping is visible and not smooth?
I actually have three problems here. Parallax and looping are working but:
Background looping is really delayed.
You can see when the background loops again. You can see it snapping mid-game and not in a smooth manner.
When the background is moving it kinda stutters very subtly but you can see the glitchy stutters it does.
Script for Parallax:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Parallax : MonoBehaviour { private float Length, StartPos; public GameObject Cam; public float ParallaxEffect;
// Start is called before the first frame update
void Start()
{
StartPos = transform.position.x;
Length = GetComponent<SpriteRenderer>().bounds.size.x;
}
// Update is called once per frame
void Update()
{
float temp = (Cam.transform.position.x * (1 - ParallaxEffect));
float dist = (Cam.transform.position.x * ParallaxEffect);
transform.position = new Vector3(StartPos + dist, transform.position.y, transform.position.z);
if (temp > StartPos + Length) StartPos += Length;
else if (temp < StartPos - Length) StartPos -= Length;
}
}
If anybody knows why this could be happening... Please... HELP!
Comment