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
0 answers

Why do I have to scale my SKScene's physicsBody by 1.5 to fit the iPhone 5 screen?

I'm making a SpriteKit game on an iPhone 5. I'm having a weird bug where the physicsBody that is supposed to represent the edges of the screen seems to be too small, and seems to require a bizarre scaling factor to be right. Here's what seems to be…
Le Mot Juiced
  • 3,761
  • 1
  • 26
  • 46
0
votes
0 answers

How to disable collision between 2 SKPhysicsBody?

I would like to add a new superpower to my superhero in a spritekit game. Once this superpower is enabled, he will be able to pass through any other SKPhysicsBody. Setting the contactTestBitMask to 0x00000000 will only disable contact detection…
user1872384
  • 6,886
  • 11
  • 61
  • 103
0
votes
1 answer

Sprite Kit collision detection and physics

Hi all I am making a game where the enemy should not be able to go through walls and items in the game like for example if there is a wall, the enemy's character should not be able to go through it. however, I can't get the physics to work exactly…
Ray
  • 161
  • 8
0
votes
1 answer

Make a certain sprite ignore SKPhysicsBody

I am having an issue making a sprite ignore the effects of a SKPhysicsBody placed as a ground platform in an iOS project. I have only one sprite that I would like to "follow the rules" of the SKPhysicsBody and for all other sprites to "pass…
Solsma Dev
  • 481
  • 6
  • 22
0
votes
2 answers

SKPhysicsBody collision detection on one side

Is it possible to detect if a node collides on only one side with another side? For example an animal that runs against another animal. In that case the collision detection method gets called. But when the animal jumps over an animal and "walks" on…
David P
  • 228
  • 2
  • 14
0
votes
1 answer

SKPhysicsJoints are all fairly wobbly and elastic

So, I have an object composed of several physics bodies with 10 or so joints holding it together (pin and fixed). It works well but I am surprised at how wobbly the joints are. I'd imagine "fixed" to be just as fixed as if I merged them into one…
Nathan
  • 139
  • 10
0
votes
0 answers

SKPhysicsContact crash - Bad Access

Ok, so I'm quite confused. I set my viewcontroller as the delegate for the physicsworld. When my Flappy Bird collides with a coin, this method gets run: - (void)didBeginContact:(SKPhysicsContact *)contact { if (contact != nil && contact.bodyA !=…
Kjell
  • 801
  • 7
  • 19
0
votes
1 answer

Multiple sprites with same SKPhysics body object

I am building an airport simulation game using sprite kit. My layout for the game states intact before adding SKPhysics body and once SKPhysicsbody is set for nodes, my sprite nodes goes wary. This is what I am adding to scene without SKPhysicsBody.…
slysid
  • 5,236
  • 7
  • 36
  • 59
0
votes
2 answers

SKPhysicsBody composition?

How can I create a concave SKPhysicsBody? My guess is to create a composite node that consists of multiple convex bodies. Can I "stick" them any other way that create an SKPhysicsJointFixed between each?
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
0
votes
3 answers

SKPhysicsBody containment test?

Any simple method to test if an SKPhysicsBody entirely contains another? Something like bodyA contains every point of bodyB, or so. Just wanted to ask you before implement some 2D math helpers to do this with additional "meta"-CGPaths attached to a…
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
0
votes
1 answer

Sprite Colliding With Screen Bottom?

My scene has a [SKPhysicsBody bodyWithEdgeLoopFromRect: self.frame]. How can I make an action when a sprite collide only with the bottom of the screen?
0
votes
1 answer

-(void)didBeginContact is not being called. Thoughts?

#import "collisionTestMyScene.h" const static int nodeBitMask = 0x1 << 0; const static int node1BitMask = 0x1 << 1;; @implementation collisionTestMyScene -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { /*…
0
votes
2 answers

Ellipse SKPhysicsBody

Which SKPhysicsBody body type would I use to create an elliptical physicsBody? I know I could make a curve out of straight lines and just have it not be a real ellipse, but it seems like there must be some way to squish a circle or create one?
Max Hudson
  • 9,961
  • 14
  • 57
  • 107
0
votes
2 answers

How to make a SKSpriteNode react for only certain collisions

In this project there are two players and both can shoot. When the opposite players bullets hits a ship, it lowers their health and disappears, this works fine. The problem is I don't want either the ships or the bullets to react to colliding into…
Lucas Bullen
  • 211
  • 5
  • 14
0
votes
1 answer

SpriteKit detect end of Contact

I'm trying to figure out how to detect when the contact between two bodies ends. I'm working on a car game something like alpine crawler and only when the rear wheel is touching the ground the car is able to accelerate. This is my code for now but…
Banjalucan
  • 115
  • 1
  • 9