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
0
votes
1 answer

SK Physics Body is not colliding with Edge Physics Body

I'm new to Sprite Kit and I'm trying to set up a simple game where a dropped object stays within the confines of the screen. When I drop the object, though, it does not collide with the edges of the screen like it should, it simply falls through. I…
cocoamoco
  • 39
  • 6
0
votes
0 answers

How to define custom physics body for custom sprites?

Very new to Sprite Kit, trying it out and making a simple game now. Say I create a .png sprite with both transparent and non-transparent parts (the object is an arbitrary shape) – can I have Sprite-kit automatically figure out the physics body…
rafalio
  • 3,928
  • 4
  • 30
  • 33
0
votes
0 answers

SpriteKit physics body fail to detect contact for thin object

I am making space shooter game with Sprite Kit. One problem I face is that it sometimes fail to detect collision between two objects if one of it moves too fast or it is too thin. One possible solution I found is setting…
Sungwon Jeong
  • 1,267
  • 2
  • 15
  • 28
0
votes
0 answers

Sprite Kit remove restitution (bounce) on specific contact

I have a contact delegate set up for some objects in sprite kit, one is dynamic and one is not. The restitution of the dynamic object is set to 0.8 (fairly bouncy) is there a way that on this contact (and only this contact) that the dynamic object…
Kyle Goslan
  • 10,748
  • 7
  • 26
  • 41
0
votes
1 answer

didBeginContact - bodyA & bodyB end Contact if one of them hits another category

Here is the deal, I've got a basket, an Apple and an Orange bodies. We are going to drop them into the basket. I also want to know the presence of the Apple inside the basket, so I go ahead and add a didEndContact method. Lets assume the apple is…
adimona
  • 127
  • 7
0
votes
0 answers

CGVector amount changes when changing scenes

In my first scene I have a CGVector value that makes a ball bounce around the screen. When loading back to this screen (from a game over screen), the value has changed making the ball move much slower than I want. First scene addBall…
George_UK
  • 61
  • 6
0
votes
1 answer

Sprite Kit - Shadow on multiple moving object affected impulse and Gravity

Base on my first question here which was answered by Theis Egeberg (The solution was explained more by Theis in the comment and worked like magic)I would need to also know the following: (This might have a simple answer but I will leave it it to…
adimona
  • 127
  • 7
0
votes
2 answers

Sprite Kit - Detecting Y due to an impulse and Gravity, if the ball is moving away or Closer to the ground

I'm creating a false shadow for an SKSpriteNode (a Ball) with physicsBody and impulse in Y direction applied to it. I like to decrease the opacity of the shadow which stays on the ground as the ball raise and decrease it back to 100% as it heads…
adimona
  • 127
  • 7
0
votes
0 answers

Spritekit drastic frame rate drop

I have tried my best to boil this question down as simple as possible. I have a coin object in my game: @implementation -(CollectableCoin*)initWithLocation:(CGPoint) Location andValue: (int) val { self = [super initWithImageNamed:@"coin"]; [self…
0
votes
1 answer

How can I implement a SKPhysicsBody object in another SKPhysicsBody object?

The scene is: one player and one box, the player is in the box. When I swipe right on the screen, the player runs to the right. When he reach the box's right edge, he will push the box to the right. So I design two SKNode CGRect box =…
jseanj
  • 1,509
  • 1
  • 9
  • 9
0
votes
1 answer

How Do I Destroy an SKPhysicsBody?

At certain points in my game I want a ton of balls to fall onto the screen. Once they hit the ground and bounce a bit, I want them to just sit there, and no longer need them to move. Once I get up to 200 physics bodies, the game gets very slow, so…
Cocorico
  • 2,319
  • 3
  • 22
  • 31
0
votes
1 answer

Collisions between SKPhysicsBodies being ignored

I'm using sprite kit for physics and collision detection in my app. I have some balls falling into a box. The inside of the box is defined using bodyWithPolygonFromPath I drop some balls into the box and they fall straight through. Here is the code…
Tiddly
  • 1,620
  • 3
  • 21
  • 43
0
votes
2 answers

SpriteKit FPS low with PhysicsBody collisions

In my SpriteKit game, I have many tile nodes (>100) arranged randomly and I need to be able to detect collisions between the tiles and the character node. To do this, I use SKPhysicsBody. I find that if I enable SKPhysicsBody code, my frame rate…
HHHH
  • 1,197
  • 2
  • 16
  • 28
0
votes
2 answers

SKPhysicBody In the Wrong position

I am creating a simple Sprite Kit game however when i am adding the PhysicsBody to one of my sprites it seems to be going in the wrong position. i know that it is in the wrong position as i have have set skView.showsPhysics = YES; and it is showing…
ObjectiveCsam
  • 204
  • 1
  • 8
0
votes
1 answer

SKPhysicsContactDelegate protocol methods not being called

In my .h file I have added the delegate as such: @interface GameScene : SKScene And in my .m file I have this -(void)didMoveToView:(SKView *)view{ self.physicsWorld.contactDelegate =…
raej2010
  • 117
  • 2
  • 9