using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Parallax : MonoBehaviour
|
|
{
|
|
private float startpos_x, startpos_y;
|
|
public GameObject cam;
|
|
public float parallaxEffect_x;
|
|
public float parallaxEffect_y;
|
|
|
|
void Start()
|
|
{
|
|
startpos_x = transform.position.x;
|
|
startpos_y = transform.position.y;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void FixedUpdate()
|
|
{
|
|
float dist_x = (cam.transform.position.x * parallaxEffect_x);
|
|
float dist_y = (cam.transform.position.y * parallaxEffect_y);
|
|
|
|
transform.position = new Vector3(startpos_x + dist_x, startpos_y + dist_y, transform.position.z);
|
|
}
|
|
}
|