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
4
votes
2 answers

Is it possible to position physicsbody to only one part of the Sprite?

Is it possible to position a physics body on a sprite? I only want a certain part of my sprite node to have collision detection, not the whole image. Heres my physics body physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: CGFloat(54.0),…
Rachel Evans
  • 120
  • 5
4
votes
1 answer

how can make a SKSpriteNode follow another one SKSpriteNode that has a physics body

Using swift, I am trying to make a SKSpriteNode (that doesn't have a physics body) follow another SKSpriteNode that has a physics body. I want this to be done when there is contact between the sprite with a physics body and another physics body. I…
chronos
  • 517
  • 1
  • 5
  • 14
4
votes
1 answer

How to reactivate contact between two physicsBody's

I'm trying to get two physicsBody, that are already in contact with each other (in fact they overlap because physicBody.collisionCategory = 0; for both physicsBody's), to restart/re-register/re-trigger their contact, on command. I've been unable to…
Krekin
  • 1,516
  • 1
  • 13
  • 24
4
votes
1 answer

How is it possible that a SpriteKit dynamic Body can tunnel through a StaticBody?

Hi I am getting a weird effect in my SpriteKit game. I have a wall around the screen, which I had created staticbody by using bodyWithEdgeLoopFromRect. By doing skView.showsPhysics = YES; all bodies are also shown in the screen. I have a ball in…
user4202109
4
votes
1 answer

Swift SpriteKit edgeLoopFromRect Issue

The following code recognizes the bottom and top edges of the scene and the ball bounces off as expected. However, the left and right edges of the scene are breached all the time. The ball goes off screen and then eventually returns back if enough…
GusGus
  • 230
  • 6
  • 16
4
votes
0 answers

radialGravityField goes nuts after a while

I'm trying to create a SpriteKit game using Swift that looks somewhat like a 2D gravity simulator, but when my objects approach a bit they go to the opposite direction with crazy speeds. This may be related with the minimumRadius, categoryBitMask or…
Tiago Marinho
  • 2,146
  • 17
  • 37
4
votes
3 answers

Changing center point of SKPhysicsBody while using 'bodyWithTexture' (SpriteKit)

It seems like the Spritekit's API does not allow to change the center of the physicsbody when using 'bodyWithTexture' (or maybe I'm missing something). I'm wondering how you get around this when using a pixel precision physicsbody. //Upper…
JRam13
  • 1,132
  • 1
  • 15
  • 25
4
votes
1 answer

Physics body size not changing with SKSpriteNode size change in Touch moved method

I am trying to create a spring launcher where when touch is moved on scene the spring will coil as much the touch is dragged down and thn launch the item above the spring on touch end method. For that i changed the size and position of SKSpriteNode…
Viper
  • 1,408
  • 9
  • 13
4
votes
1 answer

Moving physics bodies - didSimulatePhysics vs update

Where is the better place to apply moving of the sprites with physics bodies in the Spritekit game? I know that both methods are called once per frame, first update and then didSimulatePhysics just before rendering the view...What sholud be done in…
Whirlwind
  • 14,286
  • 11
  • 68
  • 157
4
votes
1 answer

Why isn't SKSpriteNode responding to applyForce or applyImpulse?

I have a sprite node that's appearing and falling in response to the gravity applied on its attached physicsBody. Great. Now, I'd like to use applyForce to push it a little bit in some direction while it's falling. Unfortunately, no matter how small…
Jess
  • 3,097
  • 2
  • 16
  • 42
4
votes
0 answers

How to make two SKPhysicsBodies NOT to collide in SpriteKit

I have a player with: categoryBitMask = playerCategory contactTestBitMask = enemyBulletCatgory This character shoots bullets with: categoryBitMask = bulletCatgory contactTestBitMask = enemyCategory but when I shot the the bullet the bullet is a…
Thomasn
  • 101
  • 5
4
votes
1 answer

Drag a SKSpriteNode (follow your finger movements) with SKPhysics (collision)

Want to drag a SKSpriteNode (follow your finger movements) with SKPhysics (collision enabled) 2 failed solutions: 1) a) Solution: Change the position of the SKSpriteNode b) Problem: The SKSpriteNode will "magically" pass through a wall unexpectedly…
user1872384
  • 6,886
  • 11
  • 61
  • 103
4
votes
3 answers

SpriteKit: detect complete node overlap

I have two SKShapeNodes – one with an edge-based SKPhysicsBody, one volume-based – and I want to detect their intersection without collision. I've got this working fine, with the SKPhysicsContactDelegate contact methods getting called as one passes…
flatpickles
  • 2,198
  • 2
  • 15
  • 21
4
votes
2 answers

Masking SKSpriteNode as liquid

I would like to create a liquid dynamics. I searched a lot, created balls moving with device motion, but I don't know how to make the balls look like liquid.. I guess it's some mask but I didn't find how to do it. Could someone help me with…
Amit Attias
  • 143
  • 7
4
votes
1 answer

Can't change SKPhysicsJointLimit maxLength after adding the joint to SKPhysicsWorld in Sprite Kit

So, I've created a ring of SKSpriteNodes which are essentially rectangles that are joined together using pin joints. I'd like to suspend this ring inside of an SKShapeNode circle. I have connected each of the nodes to the SKShapeNode using…
Greg
  • 451
  • 6
  • 13