Search code examples
3d2dphysicsscenekitskphysicsbody

2D physics activity within Scene Kit's 3D physics engine. Issues


What are the problems with use of Scene Kit's physics engine for purely 2D physics? If any...

Does constricting or otherwise disengaging one axis of movement result in overhead or any other odd activity that would or could lead to less than ideal 2D physics behaviour?

And, does anyone know if the origin of Scene Kit's physics engine is Bullet Physics?

I would rather not migrate a 2D physics engine into Scene Kit, but realise this is also possible. I'm also aware of the ability to operate Sprite Kit scenes within Scene Kit, but that's also not what I want to do.

I've been unable to find any reference to anyone using Scene Kit's physics for only 2D activity.


Solution

    1. Organize your scene so that the 2D plane you want all action to occur in is along two of the coordinate axes. For example, set up your world so that the hero can get around it in x and y, but doesn't need to move in z.

    2. Use the velocityFactor property on any physics bodies to eliminate all physics-induced effects along the axis you don't want to move in. For example, set it to (1,1,0) to let physics move the body in x and y but not z. Do the same for angularVelocityFactor if you don't want the body spinning around certain axes.