[SOLVED]DragRigidbody distance limitation.

I’m using standard DragRigidbody script in my project and i need to drag the rigidbodies that are only 20 meters around the camera. Is it possible to implement some distance limitation in to this script? If any clues pls post.

spent an hour digging… still nothing.

Ok, i’ve got it, just needed to change

if (!Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition),  hit, 100))

where [100] is desired distance to rigid body just change it to whatever you need
oh and here is a code to change the dragging object’s color (RGB) when mouse over and it is 20 meters to the camera
so you can combine those scripts to achieve nice result

function OnMouseEnter() {

var mainCamera = FindCamera(); 
var hit : RaycastHit;
   if (!Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition),  hit, 20))
      return; 
   renderer.material.color.r = 1.0;
   renderer.material.color.g = 0.0;
   renderer.material.color.b = 0.0;

}

function OnMouseExit() {
   renderer.material.color.r = 1.0;
   renderer.material.color.g = 1.0;
   renderer.material.color.b = 1.0;

}

function FindCamera ()
{
   if (camera)
      return camera;
   else
      return Camera.main;
}

P.S
Now i would like to be able to move the object being dragged forward on right mouse down is it possible?

Any ideas?

Where do I need to put that code?! attached the object or inside DragRigidbody.js?

Thanks.
Giiancarlo