using UnityEngine;
using System.Collections;

public class Follow : MonoBehaviour {

	public Transform objToFollow;

	public bool followX, followY, followZ;
	public float xOffset, yOffset, zOffset;

	private Vector3 newLoc;

	// Use this for initialization
	void Start () {
	
		//DontDestroyOnLoad(GameObject.FindGameObjectWithTag("audio"));

	}

	
	// Update is called once per frame
	void Update () {

		newLoc = objToFollow.position;

		if(!followX){
			newLoc.x = transform.position.x;
		}else{
			newLoc.x += xOffset;
		}

		if(!followY){
			newLoc.y = transform.position.y;
		}else{
			newLoc.y += yOffset;
		}

		if(!followZ){
			newLoc.z = transform.position.z;
		}else{
			newLoc.z +=zOffset;
		}

		transform.position = newLoc;
	
	}
}
