Hello,
i want to trace some possible “snaps” in my code, and after some tests i decided to use OverlapSphere instead of OnTriggerEnter, which was killing performance.
what is also good, OverlapSphere doesn’t need to have any rigid bodies attached to any of the script’s gameObjects.
so, as seen in this image, i’m using small sphere colliders that are in the available slots, and then each one has a script that does a Physics.OverlapSphere every one second or so, to avoid running it every frame.
and even though the code runs fine, sometimes it crashes and when i print the name of the “traced collider” i get the name of “centerSphere”. And after searching, and knowing that i used such a name nowhere in my code, didn’t even find anything on google about such a thing, i came here
anyone have the slightest idea what that might be?
here’s also some most critical part of the code that prints this:
function detectAutoConnections(){
var hitColliders = Physics.OverlapSphere(transform.position, coll.radius, 11);
for (var i = 0; i < hitColliders.Length; i++){
Debug.Log(gameObject.name + " - " + hitColliders*.gameObject.name);*
}
}
i invoke this function once i enable these small spheres
InvokeRepeating(“detectAutoConnections”, 0.0, 1.0); //start detecting auto-connections immediately, every 1 seconds
[15512-autosnaps.png|15512]*
i get “autoConnector - centerSphere” autoConnector is correct and good, centerSphere-i have no idea…
i’m filtering collisions on layer 11, and only these little sphere colliders belong to it. so i don’t see why it finds this strange centerSphere object…?
*