0

How can I create a concave SKPhysicsBody?

My guess is to create a composite node that consists of multiple convex bodies. Can I "stick" them any other way that create an SKPhysicsJointFixed between each?

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172

2 Answers2

1

You may want to wait a short while - I can't say it explicitly, but there's an intriguing new SKPhysicsBody method if you look at pre-release docs at developer.apple.com and search for "iOS 7.1 API Diffs".


There is another way - you can simply create new SKNodes, add your new nodes as the children of your target composite node, and attach convex SKPhysicsBodies to these child nodes.
EDIT: this will only work for non-dynamic constituent bodies, if you just want to detect contact/collision on a concave composite one that's static.

Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
Batalia
  • 2,425
  • 1
  • 17
  • 18
  • It was my guess too, but would them "stick" this way? Probaly still remains the need for joint. – Geri Borbás Feb 19 '14 at 16:26
  • You're correct - it only worked for me because my child bodies were non-dynamic (I was just testing for contact on a static concave body). Dynamic bodies will indeed fall apart. Can you please post your code where your fixed joint "tears"? – Batalia Feb 19 '14 at 16:54
  • Wow, really, `+[SKPhysicsBody bodyWithBodies:]` seems promising to me. – Geri Borbás Feb 21 '14 at 11:32
0

Create two or more SKPhysicsBody variables using convex paths, then create a union of these paths using the initializer SKPhysicsBody.bodyWithBodies. This union can be concave.

Community
  • 1
  • 1
Craig Grummitt
  • 2,945
  • 1
  • 22
  • 34