Canopy Parallax - Script without startPos and travel

Hey,

after looking at the script for a while and wondering why you subtract and add startPos in the first place, I realized that we actually just want to multiply the camera position with the parallaxOffset to get our Parallax effect.

So I simplified the script a little bit and removed the startPos and travel variable/property:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Parallax : MonoBehaviour
{
    [SerializeField] private float parallaxOffset = -0.15f;

    private Camera cam;

    private void Awake() {
        cam = Camera.main;
    }

    private void FixedUpdate() {
        transform.position = cam.transform.position * parallaxOffset;
    }
}
2 Likes

This actually fixes a screen tearing issue the original script was giving me, so thanks!

Privacy & Terms