25 lines
584 B
C#
25 lines
584 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class Parallax : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform cameraTransform;
|
|
[SerializeField] private Player.Cam playerCam;
|
|
[SerializeField] private float parallaxFactor;
|
|
|
|
private Vector3 _target;
|
|
private float _offset;
|
|
|
|
private void Awake()
|
|
{
|
|
_offset = transform.position.y - cameraTransform.position.y;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
_target.y = (cameraTransform.position.y + _offset) * parallaxFactor;
|
|
transform.position = _target;
|
|
}
|
|
}
|