Questions tagged [skphysicscontact]

A SKPhysicsContact object describes the contact between two physics bodies.

The SKPhysicsContact class is a member of the SpriteKit framework. It is used to describe a contact between two physical bodies in a physics world.

72 questions
1
vote
1 answer

Node on top of another Node, both with Physics Bodies, Only want to detect most top physics body - SpriteKit / Swift

Creating a game in Swift and SprieKit. I have 2 nodes, a BridgeNode and WaterNode. One on top of the other. Both have physics bodies to detect when the player is either on the bridge on in the water. Both nodes are added independently as child…
Leethal
  • 25
  • 4
1
vote
1 answer

How are bodyA and bodyB determined in SKPhysicsContact?

I have two different fixed SKPhysicsBody in an SKScene. The only difference between the two is their categoryBitMask. One has a categoryBitMask of 512, the other 1024. static const u_int32_t kWallCategory = 0x1 << 9; //512 static const…
rswayz
  • 1,122
  • 2
  • 10
  • 21
1
vote
0 answers

SpriteKit & Swift 3 - Bounce Not Working Properly With Ball Node

I made a game which essentially has a ball and a couple of targets and paddles. However I needed to make it so depending on what target the ball collides with the speed is either tripled, doubled or halved as long as it doesn't drop below a minimum…
user6361496
1
vote
3 answers

Spritekit- DidBeginContact not being called

I noticed this issue has happened to a lot of people. I made sure to have the self.physicsWorld.contactDelegate = self in the didMove function but it still doesn't work. Here is my code: class PoolTableScene: SKScene, SKPhysicsContactDelegate { …
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
1
vote
2 answers

SpriteKit's didBeginContact can't be called

I tested with a simple scene. Func didBeginContact can't be called. I have try to use collisionBitMask and s1.physicsBody = SKPhysicsBody(circleOfRadius: 100). The problem was persistent. What can I do to fix it? import SpriteKit class…
yao.h yao
  • 171
  • 1
  • 1
  • 4
1
vote
1 answer

iOS SpriteKit Collision Detection Fails After Decode Save

I have a game where Falling Nodes fall down and hit the Base Number Sprite Node and game logic is run from there. When I set up a new game from scratch the collision detection works exactly how it should. My problem occurs when I create a game…
1
vote
1 answer

Contact physics Gap in SpriteKit (Swift)

I am working on my first swift iOS sprite kit project but I've run into a problem that I just can't find a solution to. My goal is to have a ball land on a moving platform and the ball and platform both stop upon contact. The issue I am running into…
tim122911
  • 11
  • 2
1
vote
2 answers

How to translate SKPhysicsContact contactPoint into my SKSpriteNode position

I've spent too long on this. Someone has solved this already, please help. Enemy fires on my ship. SKPhysicsContact takes over and I get contactPoint. I explode the fired missile at the contactPoint, in world coordinates. All good. Now I would like…
julius patta
  • 78
  • 1
  • 8
1
vote
0 answers

Why does my SKShapeNode pass through an object, pausing briefly beforehand?

The code below when run on a device that’s flat on the table shows a red circle (the 'ball') and a line. When I gently tip the device the circle moves towards the line. When it reaches the line, it stops which is the expected and desired…
1
vote
1 answer

didBeginContact works absolutely incorrect swift

I have a very simple app on sprite kit for mac os. (BTW, this code for iOS is working correctly). AppDelegate code: import Cocoa import SpriteKit extension SKNode { class func unarchiveFromFile(file : String) -> SKNode? { if let path =…
pomo_mondreganto
  • 2,028
  • 2
  • 28
  • 56
1
vote
3 answers

Change direction not velocity in SpriteKit (swift)

In my game I have 2 sprites, A ball and a paddle. I'm trying to restrict the angle of reflection so that way it doesn't hit and go horizontal. I'm using this code to check the angle of contact: var impactX = contact.contactNormal.dx …
inVINCEable
  • 2,167
  • 3
  • 25
  • 49
1
vote
1 answer

Collision Bit Mask Hero passes right through EVERY thing, even the Ground

I am trying to avoid collisions between Hero and Coins, but not between Hero and Grass Ground. As soon as I apply a Collision Bit Mask to Hero, my Hero passes right through EVERY thing. I want it to pass through the Coins but not through the Grass…
Adnan Zahid
  • 573
  • 1
  • 10
  • 38
1
vote
1 answer

didBeginContact method not working as intended

I have two nodes and a boolean. Simple enough. When node A contacts Node B and the boolean is 0, nothing happens. However if the boolean is 1, Node A is removed through the didBeganContact method. Extremely simple, however I have an annoying problem…
Blank
  • 113
  • 9
1
vote
1 answer

App crashes on iPhone 4s but no other device: possible issue with SKPhysicsContactDelegate?

I've ran my spritekit game on the following devices: iPhone 5s, iPhone 4s, iPad air and iPad mini. The app runs and all the devices except the 4s. On the 4s the app crashes when the app transitions to scenes that include SKPhysicsContactDelegate,…
appsaa
  • 43
  • 8
1
vote
0 answers

SpriteKit - No Contact when Dynamic

My problem is when me hero make contact with an obstacle he rotates and gets affected by that contact, if i set dynamic = false, contact stops getting detected. here is what my hero looks like: hero.physicsBody = SKPhysicsBody(rectangleOfSize:…
Abdou023
  • 1,654
  • 2
  • 24
  • 45