简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM