30 lines
860 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*
2021.7.24
使Cam
*/
//视差类,霄酱写的🤔
public class Parallax : MonoBehaviour
{
public Transform Cam;//视差摄像机
public float moveRate;//视差率
private float startPoint;//起点,自动获取
// Start is called before the first frame update
void Start()
{
startPoint = transform.position.x;//获取当前起点位置
}
// Update is called once per frame
void Update()
{
//每帧更新位置
transform.position = new Vector2(startPoint + Cam.position.x * moveRate, transform.position.y);
}
}