using UnityEngine;
using System.Collections;

public class OscillatePosition : MonoBehaviour {

    private Vector3 originalPosition = Vector3.zero;
    public float xScalar = 1.0f;
    public float xPeriod = 1.0f;
    public float yScalar = 1.0f;
    public float yPeriod = 1.0f;

    // Use this for initialization
    void Start () {

        originalPosition = gameObject.transform.position;
	}
	
	// Update is called once per frame
	void Update () {

        Vector3 adjustment = Vector3.zero;

        if (xPeriod > Mathf.Epsilon)
            adjustment.x = xScalar * Mathf.PingPong(Time.time, xPeriod);

        if (yPeriod > Mathf.Epsilon)
            adjustment.y = yScalar * Mathf.PingPong(Time.time, yPeriod);


        gameObject.transform.position = originalPosition + adjustment;
	}
}
