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

What is SKNode "origin"?

Docs for SKPhysicsBody bodyWithCircleOfRadius: says: Creates a circular physics body centered on the owning node’s origin. So is origin a node position? Couldnt find it anywere.
Maq
  • 369
  • 3
  • 13
4
votes
1 answer

SKPhysicsJoint allow orbit around a fixed point

Using spritekit physics joints how could you make an object orbit another at a fixed distance? Object-A, should not move Object-B, should orbit Object-A when a force is applied to it To achieve this I tried attaching a SKPhysicsJointLimit limit…
nacross
  • 2,013
  • 2
  • 25
  • 37
4
votes
1 answer

perfectly elastic collisions in sprite kit

I have two balls of equal mass that hit each other straight on. I can't seem to figure out why there is a rebound effect on the incoming ball. I am using sprite kit. I thought it was the restitution property. I have it set to 1 (which is what I…
Cherr Skees
  • 1,508
  • 2
  • 21
  • 37
4
votes
2 answers

SKshapenode is not responding to Physicsbody

I have created a SKShapeNode and I have assigned a physicsBody to it. However, it is not being triggered when there is contact. Creation of SKShapeNode code: -(SKShapeNode*)gravityline{ //SKSpriteNode *lolo=[[SKSpriteNode alloc]init]; …
TALAA
  • 6,184
  • 1
  • 13
  • 21
4
votes
1 answer

Issue with physics bodies when subclassing SKSpriteNode?

I am having an issue while subclassing SKSpriteNode. Here's my implementation of the subclass: @implementation SSSquirrel - (id) init { if (self = [super init]) { // Create Squirrel and physics body SKSpriteNode *squirrel =…
jnicks
  • 39
  • 1
  • 4
4
votes
3 answers

bodyWithEdgeLoopFromRect not working in landscape

I'm just trying to set up a basic scene in landscape, with gravity, and having the scene in an edge loop. I set up the scene's physics body and the mainCharacter sprite physics body, here is my code: -(id)initWithSize:(CGSize)size { if (self =…
Nolan Anderson
  • 576
  • 1
  • 6
  • 15
4
votes
2 answers

Using Sprite Kit, how can I let an object jump?

I am making a game with sprite kit and now I am wondering what the best way is to let the object 'jump'. So it will be launched up vertical with a few pixels. This is the code of the object I want to jump: SKSpriteNode *sprite = [SKSpriteNode…
Vince
  • 648
  • 1
  • 7
  • 17
3
votes
1 answer

make SKPhysicsBody unidirectional

I have a SKSpriteNode as a ball, it's been given all the SKPhysicsBody properties move around in all direction. What I want now is to make it unidirectional (only move in that direction it hasn't move to before and not go back in to a path it had…
Frostmourne
  • 156
  • 1
  • 19
3
votes
1 answer

Change Pinned Physicsbody Position After It's Been Set

Is there a way of changing a sprites pinned position after it has been set. For example, the below has the 'top' sprite pinned to the 'base' sprite and I want to be able to move the 'top' sprite up and down as required (change the pinned y…
Jarron
  • 1,049
  • 2
  • 13
  • 29
3
votes
1 answer

How to make applyImpulse equal on all screens

As you may know when using SpriteKit, applyImpulse does not work well on all screens. On an iPhone SE, my ball moves extremely fast, but on the iPad Pro 2nd gen the ball goes really slow. Is there a way I can make this equal on all screens, in…
George
  • 25,988
  • 10
  • 79
  • 133
3
votes
1 answer

Porous Boundary

I just set up a boundary for my game which seems to be working alright until it is really forced, as in I make my character run towards it for several seconds, and then my character will just go straight through. Any explanations for this and how I…
3
votes
2 answers

SKSpriteNode slows down but shouldn't

I am trying to get my "word" to float across the screen; constant velocity, no impacts, no gravity, no friction. Everything works except the word slows down. Code for creating word: func createWordNode (word: String, atPos: CGPoint) -> SKSpriteNode…
3
votes
1 answer

Changing SKPhysicsBody while changing SKSpriteNode position

I've got quite simple game. It's like the classic Labyrinth game which uses accelereometer but user is also able to change the size of the rectangle using 3D Touch. The player's node is rectangle which moves thanks to the world's physics which gets…
mikro098
  • 2,173
  • 2
  • 32
  • 48
3
votes
3 answers

Scale a SKPhysicsBody, how?

I'm reasonably sure I've previously seen code somewhere that scales a SKPhysicsBody, but google and the docs aren't helping, making me more confused than normal. Is there a way to scale a physic's body in SpriteKit? The docs, here, don't mention…
Confused
  • 6,048
  • 6
  • 34
  • 75
3
votes
1 answer

Change a SKPhysicsBody's body shape

I don't want to change ANYTHING other than the body that defines the shape of a SKPhysicsBody. How do I do this? I can't seem to find where I can change this. Or even commentary on how to change it. Yes, I know this has to be done carefully, so…
Confused
  • 6,048
  • 6
  • 34
  • 75