Search code examples
objective-csprite-kitgame-physics

SpriteKit Collision without Tilting


I want to use native SpriteKit collision detection to keep my character in a 2D sidescroller falling through the ground (obviously.)

Here's the thing: with native SpriteKit physics, jumping at certain angles, or falling on tiles that are put diagonally would result in the sprite tilting, falling over, and doing all the other unnecessary physics.

How do I have native SpriteKit physics not tilt sprites and whatnot? Thanks!


Solution

  • The answer is simple. Set the SKPhysicsBody's allowsRotation to false.

    A Boolean value that indicates whether the physics body is affected by angular forces and impulses applied to it.