Hi guys!
I am having a hard time trying to figure out how to limit the gameObject dragging area. The code below will begin to drag a game object once you click on it but how do i apply dragging limits… like a radius limit zone! so one will not be able to drag it passed that zone… hope this make sense… Example: ball is sitting on the middle of the screen you click and drag it way from the center but once you drag it passed a certain point the ball stops following your mouse, then if you get back into the dragging zone it picks up and continues to follow your mouse…
if(Input.GetMouseButtonDown(0) ))
{
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (!Physics.Raycast (ray, hit, 10000))
return;
if(hit.transform.gameObject.tag == "ball")
{
focusObj = hit.transform.gameObject; // focusObj is set as a GameObject var
}
}