Global Game Jam 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
699 B

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);
}
}