using UnityEngine;
using System.Collections;

public class Parallax : MonoBehaviour {

	public Transform Viewer;
	public float FollowFactor;

	private Vector3 ViewOrigin;
	private Vector3 PosOrigin;


	// Use this for initialization
	void Start () {
		if(Viewer == null)
		{
			GameObject cgo = GameObject.Find ("Main Camera");
			Viewer = cgo.transform;
		}
		ViewOrigin = Viewer.position;
		PosOrigin = transform.position;
	}
	
	// Update is called once per frame
	void FixedUpdate () {

		Vector3 vdelta = (Viewer.position - ViewOrigin);
		transform.position = PosOrigin + FollowFactor * vdelta;
	
	}
}
