Questions tagged [skphysicsworld]

An SKPhysicsWorld object simulates collisions and other physical properties. You do not create SKPhysicsWorld objects directly; instead, read the physicsWorld property of an SKScene object.

An SKPhysicsWorld object simulates collisions and other physical properties. You do not create SKPhysicsWorld objects directly; instead, read the physicsWorld property of an SKScene object.

The physics world object allows you to perform the following tasks:

  • Set global properties for the simulation, such as gravity
  • Create joints between two physics bodies in the scene
  • Set a delegate to receive notifications when two physics bodies are in contact with each other
  • Determine which physics bodies within the scene intersect with points, rectangles, or rays

Click Here for Apple's Documentation of SKPhysicsWorld

61 questions
8
votes
4 answers

iOS Swift didBeginContact not being called

I have been struggling for the past two days to get two SKSpriteNodes to register a collision and evoke didBegin#contact. I've set their bit masks 'categoryBitMask', 'contactTestBitMask' and 'collisionTestBitMask' for both objects. I've also set the…
7
votes
2 answers

Pause SpriteKit game with Physics SKSpriteNode child

I have a SKSpriteNode with a dynamic physics body on a SKNode *_fgLayer. Now, when I pause or unpause the game I want that SKSpriteNode to remain in place and not rotate or fall down. If I simply use _fgLayer.paused = YES; the SKSpriteNode does not…
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
5
votes
1 answer

Why is SceneKit's physicsWorld didBeginContact firing multiple times for a single collision?

I'm using SceneKit's physicsBody system to detect collisions between objects, and getting some very strange results. To illustrate, I've got a minimal example that produces two spheres with kinematic physicsBodies and moves them in straight lines so…
Robert
  • 6,660
  • 5
  • 39
  • 62
5
votes
4 answers

iOS7 SKScene how to make a sprite bounce off the edge of the screen?

I'm building a game with balls bouncing within the iPad's screen. Similar to a Pong game. I see that SKScene's SKPhysicsWorld has gravity property, and also controls how objects collide with each other. Is there some way I can automatically detect…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
4
votes
0 answers

How to change speed of physics world for particle effects in Sprite Kit?

I created particle effects using the editor but my app is done in all code (Swift). When I change the speed of the physics world, all my physics bodies slow down just fine. But when I make my particles into a physics body, they do not get affected…
4
votes
2 answers

Set a physicsbody to a constant velocity

Moving a ball with constant velocity I tried to make a box of balls where the balls move with constant velocity. The shouldn't slow down when they collide with each other. I think I have set all properties right but it didn't work and after 30s all…
Miaucl
  • 324
  • 3
  • 17
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
2
votes
2 answers

How to make a force that doesn't accelerate objects constantly SpriteKit Swift

So I want to make a force that moves a physics object in the scene without accelerating them constantly. Just like in geometry dash. So when I use gravity it is like falling , but I don't want it to accelerate like that. Hope you understood, this…
2
votes
1 answer

Sprite Kit Physics: possible to use a fixed update?

I have a scenario where I have a fixed update happening in my scene. Every update, I would like to create a shadow, using the sprites previous position. func update(currentTime: NSTimeInterval) { shadow.position = sprite.position } Now when any…
Knight0fDragon
  • 16,609
  • 2
  • 23
  • 44
2
votes
2 answers

Apply an impulse to SKNode to move across screen and detect collision

I am making a basic app that pushes shapes across the screen and detects collision with Sprite Kit. My first attempt was using moveTo on the nodes. The issue I had was with collision, the objects would rotate around each other instead of bounce. …
StuartM
  • 6,743
  • 18
  • 84
  • 160
2
votes
1 answer

physicsWorld.bodyAlongRayStart() creating phantom println (reads 'Chance') - override println function?

I'm using Sprite Kit's built-in physics engine in a game I'm writing. In order to check whether or not a character is on the ground, I'm using the bodyAlongRayStart() function of the SKScene's physicsWorld to check for bodies underneath the…
MassivePenguin
  • 3,701
  • 4
  • 24
  • 46
2
votes
1 answer

Sprite Kit didBeginContact not called between body and edgeRect

I have a game where I'm flicking bodies off the screen. I want to detect when these bodies are coming into contact with the edges (still letting the bodies pass through to off the screen) of the screen and I've implemented everything but still it is…
Mike Simz
  • 3,976
  • 4
  • 26
  • 43
2
votes
2 answers

Stop Deceleration in SKPhysicsBody Collisions

In my SpriteKit project, I am learning to use the wonderful, built in physics engine. I am accomplishing this through the use of SKPhysicsBody instances attached to nodes, and it has worked out well so far. My current set up is when I add a node, I…
Brian Tracy
  • 6,801
  • 2
  • 33
  • 48
2
votes
2 answers

SKPhysicsContactDelegate Not Working

I have the following code: in my scene: static const uint32_t enermyCategory = 0x1 << 0; static const uint32_t fatherCategory = 0x1 << 1; self.physicsWorld.contactDelegate = self; //init ship Ship *ship = [Ship…
phil88530
  • 1,499
  • 3
  • 19
  • 27
1
2 3 4 5