Is there a way to create a concave physicsBody in SpriteKit?

末鹿安然 提交于 2019-12-12 09:58:11

问题


I have an object on scene and my hero should not go through it, but it should be able to go inside of it, like a boat into the bay, surrounded by the other element. I tried all kinds of physicsBody having it have body with rectangle, texture, with polygon from path, but to no avail. I was reading somewhere that it is not possible to have a concave physicsBody, but only convex. I really need it to be able to be concave. Does anyone know how to resolve this?


回答1:


You can create a concave physics body by adding up a bunch of convex physics bodies into one shape. Then you can add them as children to an SKNode so that they stick together. there are some physics editor apps that can help you do this so you arent writing a bunch of coordinates by hand.



来源:https://stackoverflow.com/questions/35690531/is-there-a-way-to-create-a-concave-physicsbody-in-spritekit

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