- Home /
Physics.overlapSphere doesnt detect colliders,Physics.CheckSphere doesn't detect colliders
Whenever the player can't pick up an item, or drops a few items at once, i want them to be dropped in a circle around the player. I use Check/OverLapShere to detect if there is already a spawned item, and if there is to move its position by and angle with physics.RotateAround. It works for the first item, it detects all others nearby, but the moment i move it to the second location it does not detect the items. COuld it be that because they are spawned at the same location the collider doesnt detect them since their colliders are at the same place? they are all at the same layer so that doesnt bother it Collider[] intersects = Physics.OverlapSphere(inst.transform.position, 1.3f);
Debug.Log(intersects.Length + $"lenght of colliders ->{i}");
if (intersects.Length > 1)
{
Debug.Log(inst.transform.position + "befire");
inst.transform.RotateAround(pos, parentTrans.up, 15f);
Debug.Log(inst.transform.position + "after");
}
else
{
break;
}
Answer by rage_co · Aug 03, 2021 at 04:00 PM
You are not iterating through the array with some loop....just make it...
if (intersects.Length > 1)
{
foreach(Collider intersect in intersects)
{
Debug.Log(intersect.GetComponent<Transform>().position + "before");
intersect.GetComponent<Transform>().RotateAround(pos, parentTrans.up, 15f);
Debug.Log(intersect.GetComponent<Transform>().position + "after");
}
}
Just put this in place of your if statement Sorry for the lack of proper formatting, im on my tablet and not an IDE...hope this helps