Unity3d Is there something like Mesh Collider for 2D objects?

£可爱£侵袭症+ 提交于 2019-12-12 09:15:02

问题


Im making simple 2D game, I designed the "way" the player going through in the game. If the player touches the wall the game is over, so I must detect collisions.

At first I created the walls from sprites, but then I realized there is no 2D collider that suit himself to the shape of the sprit(it was to difficult to create the collider manually from a lot of smaller polygon and circle colliders), so I made all the walls that builds the "way" 3D objects(.dae files with z=0.001), and added them the mash collider which suits himself to the 3D object. I changed my player to be 3D as well so the collisions types will match. It worked, but I'm sure the same game can work by much better performance with the same resources if all the game objects were 2D.

How can it be that there if a collider that suits himself to a 3D object but there is none for 2D? Maybe I miss something?


回答1:


At my first attempt I didn't export the sprite correctly so the polygon collider didn't recognized the shape of my sprite.

I export the sprite as JPEG, when I export it as .png it worked like a charm, just added the Polygon Collider and it match to my sprite shape perfectly, thanks!



来源:https://stackoverflow.com/questions/27831242/unity3d-is-there-something-like-mesh-collider-for-2d-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!