- Home /
Physics.OverlapSphere Problem With Rigidbody
In my game you drag and drop objects along the x-axis. I have Rigidbody components attached to each object to make the objects interact the way I want. It's vital that I keep track of the exact order of these objects. I'm using Physics.OverlapSphere to do this.
However, the array does not update as I move the objects around and change their order. Only when I remove the Rigidbody components from all the objects does the array update to reflect the new object order. I've tried temporarily removing the Rigidbody components, moving the objects and then adding Rigidbody back again but as soon as I do, the array jumps back to the starting order.
Here is the code that I'm using:
public var overlapLayer : LayerMask;
var location : Vector3;
var radius : float;
var objectsNear : Collider[];
function Update () {
objectsNear = Physics.OverlapSphere(location, radius, overlapLayer);
for (var colliderOverlap : Collider in objectsNear){
print (colliderOverlap);
}
}
Have I set Physics.OverlapSphere up wrong or does it not work the way I'm trying to use it?
Answer by Wasabi667 · Sep 02, 2013 at 12:17 AM
It seems to be very easy. It is the Rigid body Attribute "Collision Detection" with Discrete the Collision got optimized away. In other Collision Detection modes it works as expected.
Even if this is an answer to a more than 1 1/2 year old question, I hope it helps somebody.
Your answer
Follow this Question
Related Questions
Physics.OverlapSphere not including object 2 Answers
Aircraft Control 1 Answer
Pinwheel prevents player by moving 0 Answers
custom rigidbody movement problem 2 Answers
My dragrigidbodies script makes the carried object jittery 0 Answers