I can't figure out how to get around this. I added a dragrigidbody.js to an object, but when a collider is in front, it won't work! please help and I would greatly appreciate it. the thing is, I don't know how to Javascript. Thanks very much, Not showing my name.
the DragRigidBody script uses Raycasting to check if your mouse is over some object. The way raycasting works is by "shooting" an imaginary ray until it hits an object with a collider. Then it checks if that object also has a RigidBody on it.
Since there's another collider in front of the object you want to drag - the script stops there (and does nothing since that collider doesn't have a RigidBody component on it).
Try editing the script to use Physics.RaycastAll instead of Physics.Raycast... Try changing:
if (!Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), hit, 100))
return;
// We need to hit a rigidbody that is not kinematic
if (!hit.rigidbody || hit.rigidbody.isKinematic)
return;
To:
var hits : RaycastHit[];
hits = Physics.RaycastAll (transform.position, transform.forward, 100.0);
for (var i=0;i<hits.length;i++)
{
var currHit : RaycastHit = hits*;*
*// We need to hit a rigidbody that is not kinematic*
*if (currHit.rigidbody && !currHit.rigidbody.isKinematic)*
*{*
*hit = currHit;*
*break;*
*}*
*}*
*```*
*<p>I'm afraid you won't get very far without knowing at least some javascript... It's not that hard, and might even be fun :)</p>*