- Home /
multiple colliders
i tried to add multiple colliders to my object that have highlight script attached to it so it reacts to mouseover. first i thought it should be enough to add two spheres at the end and one box collider in the middle instead using expensive mesh collider. but i was surprised when i got the error that i cannot add the same type of the collider to one object. then i found some topics in the forum and tried to add collider to the empty gameobject as child. but then mouse over function would not work.... so how to deal with this problem? is it possible to have mouseover script and multiple colliders in the same time.
is the mesh collider expensive after all? if i use low poly count can it be fast as box and sphere colliders? at least not to cause fps to drop significantly?
thanks!
Answer by The_r0nin · Nov 19, 2010 at 04:38 PM
When you say that you added an empty gameobject to your original object and attached a collider component to it, where was your "highlight" script (on the original object or on the new object)?
If you have an object you want to behave in a certain way during mouseover, put the script with the effect function on the object. Then create your collider objects as children and put the mouseover script on them. Then when the individual objects are "moused-over" have the mouseover script call the function on the parent object to create the effect.
Seriously, though, unless you are well along in your game and have already hit a performance roadblock, why not use a mesh collider? Optimization is best left for after you have a working game with a problem. Why spend tons of time working around a "problem" that might never actually be one? JMHO...
i have something that is usable and now trying to optimize things you are right. i have the biggest impact at fps during game because of the mesh colliders. i have this capsule that is attached to the camera which when collides with other objects make them fade out, so i need to use as precise collider as possible. ontriggerenter start the fading. so maybe i am missing something, maybe i could optimize the script that is doing the fading...
Well, try adding 3 empty child objects with the colliders and pass the collisions up to the parent. That might work for you.
Also, are you check for the collision every frame? If you use a toggle for mouseover/mouseleave, you could probably only check for a change every few frames and no one would notice...
Your answer
Follow this Question
Related Questions
Retrieving Multiple RaycastHit Colliders 1 Answer
how to add colliders to several objects? 1 Answer
Turn off all Colliders from Scene 1 Answer
Multiple Colliders Issue 3 Answers
physics.OverlapSphere colliders 1 Answer