using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InstantFollow : MonoBehaviour {

	public Transform Target;
	private Vector3 offset;
	private Vector3 iniPos;
	private Vector3 newPos;
	public bool KeepX,KeepY,KeepZ;

	// Use this for initialization
	void Awake () {
		iniPos = transform.position;
		offset = transform.position-Target.position;
	}
	
	// Update is called once per frame
	void Update () {
		newPos = Target.position+offset;
		if(KeepX) {
			newPos.x = iniPos.x;
		}

		if(KeepY) {
			newPos.y = iniPos.y;
		}

		if(KeepZ) {
			newPos.z = iniPos.z;
		}
		
		transform.position = newPos;
	}
}
