using UnityEngine;

public class ObjectMove : MonoBehaviour
{
	public float disableGravityTime;
	bool disabled;
	float baseHeight;
	float randomOffset;

	Rigidbody body;

	void Start()
	{
		body = GetComponent<Rigidbody>();
	}

	void Update()
	{
		if(disableGravityTime > 0f)
		{
			disableGravityTime -= Time.deltaTime;
		}

		if(!disabled && disableGravityTime <= 0)
		{
			this.GetComponent<Rigidbody>().useGravity = false;
			baseHeight = this.transform.position.y;
			randomOffset = Random.Range(1f, 4f);
			disabled = true;
		}

		if(disabled)
		{
			body.velocity = Vector3.zero;
			body.MovePosition(this.transform.position + new Vector3(0, (Mathf.Sin(Time.fixedTime * 5f + randomOffset)) * 0.05f, 0));
		}
	}
}
