Right now I have a script attached to a prefab. It’s called “Dynamic Number”. This prefab has a box collider that is a trigger, and it is enabled by default. The prefab is used by a spawn manager class to spawn a bunch of instances. This works fine.
In the script attached to the prefab (called DynamicNumber.cs), I have an onTriggerEnter method. I want this method to disable the box collider on the instance through which the collision has occured. So my onTriggerEnter has these lines, which I think should accomplish this goal:
However, the result of colliding with one box collider associated with the Dynamic Number prefab seems to trigger all the other box colliders as well. So rather than disabling just the one instance’s box collider, every instance of Dynamic Number has its box collider disabled. It’s almost like it does not see these instances or box colliders as unique.
Has anyone else encountered this? Am I missing something important?
This creates a similar problem across all the instatiated objects’ Box Colliders. Instead of changing the one box collider through which a collision/trigger entered has occurred, it changes every box collider of the same type.
I don’t understand why instantiating the object does not create a unique box collider object for that instance. this is very strange.
Unfortunately this does not work. The issue seems to be that whenever my player enters a trigger of an instance of Dynamic Number, every other instance of Dynamic Number has its “onTriggerEntered” method called. I don’t understand why these are not each separate instances, and why they are all linked?? Is this normal?
I have the same problem. I have a wall prefab (empty object) with brick children (rigidbody and collider). When I hit them I am adding a explosion but I don’t want the exploded bricks to hit anything else so I am disabling their collider. So the collision only works on the first 2 walls, the third one just ignore everything and I can see on the editor their box colliders are disabled.
ok, on my case the problem was about me selecting too many colliders using Physics.OverlapSphere(transform.position, 2);
so the second and third wall children were being selected together. I solved it by using a box for the overlap and narrow the children affected