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.

iOS development with Swift - book: video course:

Tagged with:
Posted in Objective C, Swift

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: