// Update is called once per frame
	void Update () 
	{
		if (heldObject != null)
		{
			if (!BuildState_Manager.isBuildTime) 
			{
				RemoveCurrentObject (true);	
				// TODO
				return;
			}

			if (!heldObjectBehaviour)
			{
				heldObjectBehaviour = heldObject.GetComponent <PickUp_Behaviour> ();
			}
			heldObjectBehaviour.held = true;
	
			RaycastHit hit = GetMouseRay ();
			if (hit.point !=  Vector3.zero)
			{
				Vector3 placePoint = hit.point;
				if (Util.CloseTo (hit.point.y, 0f, 0.05f))
				{
					placePoint.y = buildPlane.transform.position.y;
				}
				heldObject.transform.position = Util.RoundVector3 (placePoint) + heldObjectBehaviour.PlaceIndentVector;
			}
		}

		// if gravity is on, then disable buildplane, if it isn't, enable it
		buildPlane.GetComponent <BoxCollider> ().isTrigger = PickUp_GravityManager.useGravity;

		// decrease pickUpTime
		pickUpTime -= Time.deltaTime;

		GetInput ();



	}
	public void RemoveCurrentObject (bool delete)
	{
		if (heldObject)
		{
			print ("PLACING BLOCK");
			// set the lastStillPos for snapping to grid functions
			heldObjectBehaviour.lastStillPos = heldObject.transform.position;
			heldObjectBehaviour.lastStillRot = heldObject.transform.rotation;

			// delete all pointers to heldObjectBehaviour and heldObject
			if (heldObjectBehaviour)
			{
				// the object is no longer held
				heldObjectBehaviour.held = false;
			}
			heldObject.transform.SetParent (null);
			heldObjectBehaviour = null;

			if (heldObjectIsPurchased)
			{
				
			}

			if (delete)
			{ // if we are meant to actually delete the object, destroy it
				GameObject.Destroy (heldObject);
			}

			heldObject = null;

		}
	}