Got this script to select an object in a scene. What I would like to do is to restrict the area where the raycast will be made. So how I can I say I want the raycast to be between 10 and 50 in X and 10 and 100 in Y, for example?
var hit : RaycastHit;
var pickedObject : GameObject;
var selectedObject : Collider;
while (true)
{
// Use Raycast to pick object
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Input.GetMouseButtonDown (0) ){
print(ray);
if (Physics.Raycast (ray, hit, 100)) {
// if (! pickedObject)
selectedObject = hit.collider;
if (selectedObject.name == "SphereBob")
{
print ("It's a sphere SphereBob");
}
else
{
print ("It's something else");
}
}
else
{
print ("Clicked nothing");
}
}
// Wait for next frame
yield;
}