#pragma strict
private enum Direction{x,y,z};
public var sine:boolean = true;
public var local:boolean = true;
public var direction:Direction = Direction.x;
public var frequencyDirection:Direction = Direction.z;
public var frequency:float = 1;
public var amplitude:float=1;
public var phase:float = 0;
public var phasePerSecond:float = 1;
public var phaseStartingOffset:float = 0;
private var startPosition:Vector3 = Vector3.zero;
function Start () {
	phase *= Mathf.PI*2;
	phaseStartingOffset*=Mathf.PI*2;
	phasePerSecond*=Mathf.PI*2;
	if(local)startPosition = transform.localPosition;
	else startPosition = transform.position;
	phase += startPosition[frequencyDirection]*phaseStartingOffset;
}

function Update () {
	phase +=phasePerSecond*Time.deltaTime;
	var angle:float = 0f;
	if(sine)angle = Mathf.Sin(Mathf.PI*2*frequency/100*transform.position[frequencyDirection]+phase)*amplitude;
	else angle = Mathf.Cos(Mathf.PI*2*frequency/100*transform.position[frequencyDirection]+phase)*amplitude;
	if(local){
		if(direction == Direction.x)transform.localPosition.x = startPosition.x+angle;
		else if(direction == Direction.y)transform.localPosition.y = startPosition.y+angle;
		else transform.localPosition.z = startPosition.z+angle;
	}else{
		if(direction == Direction.x)transform.position.x = startPosition.x+angle;
		else if(direction == Direction.y)transform.position.y = startPosition.y+angle;
		else transform.position.z = startPosition.z+angle;
	}
}