Added space background
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Parallax : MonoBehaviour
|
||||
{
|
||||
[Header("Set in Inspector")]
|
||||
public GameObject poi;
|
||||
public GameObject[] panels;
|
||||
public float scrollSpeed = -30f;
|
||||
public float motionMult = 0.25f;
|
||||
private float panelHt;
|
||||
private float depth;
|
||||
|
||||
void Start() {
|
||||
panelHt = panels[0].transform.localScale.y;
|
||||
depth = panels[0].transform.position.z;
|
||||
panels[0].transform.position = new Vector3(0,0,depth);
|
||||
panels[1].transform.position = new Vector3(0,panelHt,depth);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
float tY, tX = 0;
|
||||
tY = Time.time * scrollSpeed % panelHt + (panelHt*0.5f);
|
||||
if (poi != null) {
|
||||
tX = -poi.transform.position.x * motionMult;
|
||||
}
|
||||
panels[0].transform.position = new Vector3(tX, tY, depth);
|
||||
if (tY >= 0) {
|
||||
panels[1].transform.position = new Vector3(tX, tY - panelHt, depth);
|
||||
} else {
|
||||
panels[1].transform.position = new Vector3(tX, tY + panelHt, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05a8662bc8c9b214d911dc2cd95c7725
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user