Reputation: 67862
I have 10 square nodes with square physics bodies in a row. How can I best merge these physics bodies to create a single skphysicsbody?
The reason I need to do this is that a square object traveling on top of the square row "trips" at random. If I replace the 10 square nodes with a single rectangle, there's no "tripping" behavior.
My current best guess is this:
Create a superset rectangle, then use SKPhysicsBody(edgeChainFromPath:)
. Then create a node just for physics and add position it somehow in the scene. In more complex scenarios I'll have all sorts of different polygons in two dimensions, so I'm not sure how I would position the physics node.
Is there a better way? If not, how do I position the physics node?
Upvotes: 1
Views: 107
Reputation: 16837
You can make a body of bodies with SKPhysicsBody(bodies:[SKPhysicsBody])
https://developer.apple.com/reference/spritekit/skphysicsbody/1519736-init
Upvotes: 0
Reputation: 67862
While not the answer to the question, using multiple physics bodies works great. My main issue is a rectangle sliding across rectangles. Using a non-visible circle removes the issue of rectangles tripping on each other entirely.
Thanks to @Confused in the comments.
Upvotes: 0