How to create a concave SKPhysicsBody

I’m building a game using SpriteKit, and using the brilliant SKPhysicsBody Path Generator.

I came across a limitation of physics bodies, that their shapes need to be convex, or an error is generated(strangely, the simulator doesn’t seem to mind, but the device does!)

How to create a concave SKPhysicsBody? Create two SKPhysicsBody variables, using convex paths. You can now generate another SKPhysicsBody variable by performing a union on the two physics bodies, using the SKPhysicsBody initializer (bodyWithBodies). The two paths are convex, but the resulting body can be concave! You can achieve more complex shapes by performing a union of more than two physics bodies.

Interactive developer, Author - iOS development with Swift - book coming 2017 https://manning.com/books/ios-development-with-swift

Tagged with:
Posted in Objective C, Swift

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: