Quantcast
Viewing latest article 12
Browse Latest Browse All 90

Answer by Matt-Downey

My best guess would be to add a co-routine that is called every 1-5 seconds that sorts through the nearest objects and either enables or disables the collider based on whether or not they are within a certain distance. This would be a global co-routine, so the script can be separated for organization sake. Although this is not sorting, I'm sort of referencing tonyd's post here: http://forum.unity3d.com/threads/136097-sorting-arrays var thisTrans : Transform; var allObjects = GameObject .FindObjectsOfType (GameObject ); for (var obj in allObjects) { var v3 : Vector3; var m : float; //magnitudeSquared v3 = obj.transform.position - thisTrans.position; m = v3.magnitudeSquared; if(m > 9000) // if the magnitude is greater than 30 root 10, or approx 95 meters { obj.collider.enabled = false; } else { obj.collider.enabled = true; } }

Viewing latest article 12
Browse Latest Browse All 90

Trending Articles