Questions tagged [skphysicsbody]

An SKPhysicsBody object is used to add physics simulation to a node. When a scene processes a new frame, it performs physics calculations on physics bodies attached to nodes in the scene. These calculations include gravity, friction, and collisions with other bodies. You can also apply your own forces and impulses to a body. After the scene completes these calculations, it updates the positions and orientations of the node objects.

An SKPhysicsBody object is used to add physics simulation to a node. When a scene processes a new frame, it performs physics calculations on physics bodies attached to nodes in the scene. These calculations include gravity, friction, and collisions with other bodies. You can also apply your own forces and impulses to a body. After the scene completes these calculations, it updates the positions and orientations of the node objects.

To add physics to a node, create and configure an SKPhysicsBody object and then assign it to the physicsBody property of the SKNode object. A physics body must be associated with a node object before you apply forces or impulses to it.

Click Here for Apple's Documentation of SKPhysicsBody.

812 questions
6
votes
2 answers

SpriteKit PhysicsBody: Could not create physics body for basic shape

I have an extremely basic polygon that is the texture for a sprite in my game, yet when I try and create a physicsBody from this texture for the sprite I get this error: 2016-06-19 08:25:21.707 Space Escape[14677:5651144] PhysicsBody: Could not…
6
votes
4 answers

SpriteKit SKPhysicsBody collision in one direction like a door you can only go through but not back

In SpriteKit SKPhysicsBody is it possible to have an object you can pass through but not go back. The idea is their is no collision in one direction so you go through and not go back, like a trap door.
Mike Zriel
  • 1,575
  • 1
  • 17
  • 28
6
votes
3 answers

Determine angular momentum from angular velocity for SKSpriteNode

I have an node in space (no angular dampening, no friction, no gravity) and I apply a torque to it (20 newton meters) over 1 second. It begins to spin and will continue forever. If I apply an inverse force (-20 newton meters) it comes to a…
BadPirate
  • 25,802
  • 10
  • 92
  • 123
6
votes
0 answers

Spritekit physic different on iOS 7.x and iOS 8.x?

Why would the sprite kit physic be different on iOS 7.x vs iOS 8.x??? I have a simple spritekit scene... I have 2 static pins and in between I have sprites which are connected by a spring joint, dropping an object on this elastic rope would behave…
Bluedays
  • 151
  • 5
6
votes
2 answers

Stop SKSpriteNode from slowing down

I am trying to keep my SKSpriteNodes moving at a constant speed forever, even after collisions. I have set gravity to 0, friction to 0, and linear and angular dampening to zero, but the Sprites still slowly slow down to zero velocity. How can I keep…
Siriss
  • 3,737
  • 4
  • 32
  • 65
6
votes
3 answers

Sprite Kit - Determine vector of swipe gesture to flick sprite

I have a game where circular objects shoot up from the bottom of the screen and I would like to be able to swipe them to flick them in the direction of my swipe. My issue is, I don't know how to calculate the vector/direction of the swipe in order…
Mike Simz
  • 3,976
  • 4
  • 26
  • 43
6
votes
2 answers

Swift SpriteKit PhysicsBody forced as optional by Xcode

im having the following issue trying to code a flappy birds clone in Xcode 6 beta 7 with Swift and SpriteKit. After I add the physicsBody property to a SKSpriteNode I cannot change a property of physicsBody directly, for instance I cannot do the…
6
votes
1 answer

SKPhysics: Made a rope, why does it break?

I've been experimenting with sprite kit a little bit, building a prototype for an idea I have. I've been connecting a string of physics bodies together using an SKPhysicsJointPin, to make a rope (actually more like a bike chain, but it's good…
Emiel
  • 1,474
  • 1
  • 13
  • 16
6
votes
2 answers

Sprite Kit Physics Collision Issue

I'm having an issue with some collisions. I have two objects equal size and mass. When one collides into another that is at rest I get the correct behavior (grey area in image). When I have two objects that are next to each other the behavior…
Cherr Skees
  • 1,508
  • 2
  • 21
  • 37
6
votes
1 answer

Not able to apply impulse to SKSpriteNode physics body

I am new to xcode's sprite kit and I'm an trying to apply an impulse to a SKSpriteNode's physics body. Here is how I create the scene: self.backgroundColor = [SKColor colorWithRed:0 green:0 blue:0 alpha:1.0]; self.physicsBody =…
Lucas Bullen
  • 211
  • 5
  • 14
5
votes
1 answer

Collision between two nodes not detected ARKit

I created two nodes: a sphere and a box: var sphere = SCNNode(geometry: SCNSphere(radius: 0.005)) //I get the box node from scn file let boxScene = SCNScene(named: "art.scnassets/world.scn")! var boxNode: SCNNode? I want two nodes…
Edoardo
  • 657
  • 7
  • 24
5
votes
1 answer

iOS SpriteKit - collisions and contacts not working as expected

Sometimes in my SpriteKit programs, my collisions and contacts (using SKPhysicsBody) don't trigger or work as expected. I think I have set up everything I need, but I am still not getting the right interactions. Is there some code I can write that…
Steve Ives
  • 7,894
  • 3
  • 24
  • 55
5
votes
2 answers

SpriteKit SKPhysicsBody with Inner Edges

I have created an SKSpriteNode called let's say Map that has an edge path that I have defined (some simple polygon shape). What I am trying to figure out is how to add several other edge paths that would act as interior edges of the Map. As if the…
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
5
votes
1 answer

Swift SpriteKit making physicsbody from texture of an image slows down my app too much

I'm trying to make an iOS app that includes some collision detection between two physics bodies. I want one of the physics bodies to be the shape of an image I am using, but when I try to do this using a texture it slows my app down tremendously and…
Jason Cook
  • 51
  • 1
  • 2
5
votes
1 answer

SKPhysicsBody ball won't bounce if impulse is too small

I have an infinitely bouncing ball simulation that works properly. The ball bounces around the screen borders forever. One minor problem though is that if the starting impulse is too small the ball never bounces to begin with. I experimented and…
shwick
  • 4,277
  • 6
  • 21
  • 28
1 2
3
54 55