Unity3d 是否有类似 Mesh Collider 的 2D 对象? [英] Unity3d Is there something like Mesh Collider for 2D objects?

查看:30
本文介绍了Unity3d 是否有类似 Mesh Collider 的 2D 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作简单的 2D 游戏,我设计了玩家在游戏中经历的方式".如果玩家碰到墙,游戏就结束了,所以我必须检测碰撞.

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.

起初我从精灵创建墙壁,但后来我意识到没有适合自己的精灵形状的 2D 碰撞器(很难从许多较小的多边形和圆形碰撞器手动创建碰撞器),所以我制作了所有构建方式"3D 对象(z=0.001 的 .dae 文件)的墙,并将它们添加到适合自己的 3D 对象的混合碰撞器.我也将我的播放器更改为 3D,因此碰撞类型将匹配.它奏效了,但我确信如果所有游戏对象都是 2D 的,同样的游戏可以在相同的资源下以更好的性能运行.

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.

如果一个对撞机适合 3D 对象,但没有适合 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?

推荐答案

在我第一次尝试时,我没有正确导出精灵,因此多边形碰撞器无法识别我的精灵的形状.

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

我将精灵导出为 JPEG,当我将其导出为 .png 时它就像一个魅力,只是添加了 Polygon Collider 并且它完美地匹配了我的精灵形状,谢谢!

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!

这篇关于Unity3d 是否有类似 Mesh Collider 的 2D 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆