- Home /
Parallax background hiccup when resetting camera position
Hello i need some help with a parallax background script. void Update() {
float temp = (cam.transform.position.x * (1 - parallexEffect));
float dist = (cam.transform.position.x * parallexEffect);
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;
}
The code works perfectly fine, but i use it for an endless runner game. When the player reaches a certain point in x axis to avoid float point precision problems i reset every objects positions. When that happens
float temp = (cam.transform.position.x * (1 - parallexEffect));
float dist = (cam.transform.position.x * parallexEffect);
is getting obviously messed up since the camera got repositioned resulting in a "hiccup" in the background images. Is there anyway to fix that? Thanks in advance
Your answer
Follow this Question
Related Questions
I'm having trouble with Color.Lerp() 0 Answers
Moving Background with translated images 1 Answer
How can I make a quad render below absolutely everything else? 1 Answer
Why can't I see my objects in the scene view when adding a background image and a background camera? 1 Answer
How do I create a shmup in Unity? 2 Answers