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

Swift/SpriteKit - Ball node downwards angle of release

I need the ball node to be be initially released in my game in a downwards angle (which is randomly generated each time). I found out the velocity of the ball includes both the direction and speed (please correct me if this is wrong) therefore I…
Antonio C
  • 71
  • 1
  • 9
3
votes
0 answers

Using SKPhysicsBody(bodies:) to create one physics body from several

I'm trying to create a single physics body from several other bodies using the SKPhysicsBody(bodies:) init. I have nodes throughout my scene that have physics bodies attached to them, and I want to consolidate them into a single physics body. I'm…
claassenApps
  • 1,137
  • 7
  • 14
3
votes
1 answer

Adding Collision Detection to SKTileMapNode

What's the recommended way of adding collision detection to an SKTileMapNode for a side scroller? Say I have a simple tilemap with just one single tile to use as the ground, how can I detect when my player sprite lands on one of the filled ground…
Sawyer05
  • 1,604
  • 2
  • 22
  • 37
3
votes
2 answers

swift usesPreciseCollisionDetection does not work?

i have made an app where you need to shoot on an enemy but sometimes the bullet goes through the enemy. swift sprite kit game when I shoot on a enemy sometimes the bullet goes trough the enemy, how can I fix this? so i added…
TimeParadox
  • 197
  • 1
  • 2
  • 16
3
votes
1 answer

Swift game collision detection and physics - sprites and background

I'm learning Swift to create a game for iOS, but I'm struggling to work out how the sprites will collide and interact with the background. The basic game will be a ball that you guide down a maze, but the maze can be several times bigger than the…
3
votes
1 answer

Replicate custom SKAction spiral movement with SKPhysicsBody methods

I recently changed some trigonometric functions to get 4 methods that move an object by creating a spiral path (as described in the code below) : From right to left to the top From left to right to down From right to left to down From left to right…
Alessandro Ornano
  • 34,887
  • 11
  • 106
  • 133
3
votes
2 answers

How to create multiple node characters in sprite kit /SKphysics joint?

I am creating a game and for my character his legs and torso have separate animations so they are separate nodes with separate physics bodies. I am having a lot of trouble linking the torso and the legs together however, linking them is not the…
gkolman
  • 189
  • 10
3
votes
1 answer

How to give a physics body to an arc?

I have two arcs that form a circle(SKCropNode), each with a different color. I know I can give the whole circle a circleOfRadius, but I was wondering if it was possible to give just one arc a physics body to fit the shape of the arc. Help much…
KeepItSimple
  • 133
  • 8
3
votes
1 answer

How do I maintain child SKNode velocities when moving the parent?

I'm working on a game in Swift with SpriteKit. I have a parent node with an SKPhysicsBody and several subnodes with their own physics bodies. All of the subnodes have some velocity relative to the parent node. How do I keep that relative velocity…
Sid Mani
  • 369
  • 3
  • 9
3
votes
1 answer

Pause Sprite Kit game with physics doesn't work correctly on iOS 9

I have a problem in pausing a sprite kit game with physics. The game contains a ball which moves in the SpriteScene and has the following parameters: self.ball.physicsBody.friction = 0; self.ball.physicsBody.linearDamping =…
Amani Elsaed
  • 1,558
  • 2
  • 21
  • 36
3
votes
1 answer

Swift SpriteKit Collisions Registered Multiple Times

I'm using SpriteKit and Swift to build an iPhone game, and my collision detection system is not functioning as I want it to. When my "bullet" physics body and my "player" physics body collide, the collision detection function is being called…
3
votes
1 answer

SpriteKit physics bodies not colliding when connected with joints

I am evaluating the iOS SpriteKit physics engine, and for a test I have created a simple scene with Xcode that contains two circle-shaped nodes: Both nodes have physics bodies of circular shape and 5 kg of mass. I am connecting both nodes with a…
bio
  • 669
  • 4
  • 14
3
votes
2 answers

Adding SKPhysicsBody causes the SKSpriteNode to shake

I have two SkSpriteNodes called left-ball and right-ball.THey flow from sides of the screen. I implemented the collision detection for these two balls. However I noticed that before I add collision detection, the balls were moving smoothly without…
Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
3
votes
3 answers

How do I draw a filled circle using SpriteKit?

I am trying to draw a filled circle in SpriteKit. I am currently drawing a circle as such. node.physicsBody = SKPhysicsBody(circleOfRadius: radius) node.fillColor = color node.strokeColor = node.fillColor I need this circle to be filled at a…
Sudeep
  • 796
  • 6
  • 16
3
votes
1 answer

More than one SKPhysicsBody from texture with alpha

I'm trying to create a SKPhysicsBody from a texture containing alpha values dynamically. Unfortunately the SKPhysicsBody is created from just one piece in the texture. How can I solve that? Here's how the SKPhysicsBody is being created: physicsBody…
DrDigg0R
  • 51
  • 5