- Home /
Is it possible to have multiple Mesh Colliders on a Gameobject?
I'm making a procedurally generated 2D level for my game and I was wondering is it possible to have multiple mesh colliders on a game object. I'm trying to have areas in my level where there is water that the player can swim in so I need to set the collider to allow the player to pass through the actual water tiles. I have looked all over and there are no answers that come close to what I am looking for.
I think I don't understood, it's tile generated ? If yes, you can't put the collider on the generated object ? And instantiate the object as prefab ?
The gameobject itself wont be instantiated. I should have worded my post better. I am generating the tilemap from a tile map editor I created. I want the tiles in the map to be linked to a mesh collider based on the value of a specific tile. So if the Tile is water it will be for $$anonymous$$esh collider 1# and if it isn't then it will be for $$anonymous$$esh Collider 2#.
Well it seems that I will have to make a few child gameobjects to solve this problem since your not allowed to have multiple colliders of the same type on a gameobject. :(
Answer by ZenithCode · Sep 03, 2013 at 08:10 PM
You can have more than 1 collider on the same object but not of the same type. E.g. 2 mesh colliders.
My suggestion would be to NOT use a mesh collider. Use a box collider instead as its much better for performance. Also, as you said create a number of childobjects referencing the same material and mesh to create your water area.
Yes you can have more than one collider! I got 8 on my player checking for multiple things!
Edited my answer now. I wanted to say that he cannot have multiple mesh colliders on the same object although I still don't suggest having multiple colliders on the same object except in special cases.
Oh ok thanks. The box collider would be a good Idea except I have the mesh for my tilemap being generated by code. So everytime i draw a new tile or draw over a new Tile I have to redraw the mesh and a single box collider wont work for this situation.
Yes the problem is solved. I just added another tilemap to the scene. I figure I can use this for tiles that would be used for water. This would allow me to allow the player to do things like swim, float, or take damage.
Answer by palbanagar · Jul 07, 2019 at 08:19 PM
select all the child objects with mesh and then assign a mesh collider. It will assign the respective mesh colliders to each one of them.,Select all the child objects and and assign a mesh collider. It wil assign the respective mesh colliders to all of them
Your answer
Follow this Question
Related Questions
OnTriggerStay2D not working 0 Answers
Best way to organize and access several distinct health values in one object 1 Answer
How do I display two scenes at once 1 Answer
please help me with AR multiple object 0 Answers
Two trigger activation. 1 Answer