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

Class Method not invoked in didBeginContact method

I created two classes: one to handle projectiles and the main scene itself. When I call the class method to spawn projectiles, in the didMoveToView or any other method, it works and I'm able to see the projectiles. However, when I want the…
Blank
  • 113
  • 9
1
vote
3 answers

beginner swift sprite kit - node collision detection help (SKPhysicsContact)

I want a sprite to delete itself when touching another sprite. Right now when they touch, they just push each other. I have this: let alphaCategory: UInt32 = 0x1 << 0 let betaCategory: UInt32 = 0x1 << 1 I made the sprites dynamic and not affected…
wanksta11
  • 59
  • 4
  • 9
1
vote
1 answer

SKPhysicsContactDelegate methods called with PhysicsKit types?

I added some convenience methods to SKPhysicsBody to more easily cope with them inside the didBeginContact method of the SKPhysicsContactDelegate class. @interface SKPhysicsBody (MyCategory) -(void)convenience; @end It appears the delegate uses…
Pieter
  • 17,435
  • 8
  • 50
  • 89
0
votes
1 answer

Phantom Button in SpriteKit Scene

I have a simple game in which players get three rounds to achieve the highest score . The gameScene exists inside a SwiftUI View and is created like this: var gameScene: SKScene { let scene = NyonindoGameScene( size: CGSize( …
Hyoryusha
  • 175
  • 1
  • 11
0
votes
1 answer

EdgeFromLoop doesn't seem to call didBegin?

I'm trying to write a game where stars are falling from the top of the iphone screen to the bottom. I want to remove my star sprites when they're out of the screen. I've tried to use physicsContactDelegate, and create a edge around my frame with…
Shisui
  • 1,051
  • 1
  • 8
  • 23
0
votes
1 answer

SOLVED: Prevent Sprite from being tilted when collide?

How can I prevent two sprite nodes from being tilted when colliding. Let say I have a long rectangle with PhysicsBody 1 and a short rectangle with PhysicsBody 2. I want these 2 to hit, but don't want the long rectangle to be tilted after colliding…
0
votes
0 answers

Cannot detect collisions in spritekit

I am trying to build a game and my physics body contacts are not being detected. Can you pls help me? I have set the physicsWorldDelegate and categorybitmasks but cannot figure out what is wrong. The playground couldn't detect the collisions between…
0
votes
1 answer

How to change the fillColor of a SKShapeNode within the didBegin contact function?

My goal is to change the fillColor of a SKShapeNode as soon as that node collides with another Node. I do know how to edit the physics body at the point of collision but I couldn't manage to figure out how to change properties like fill- or…
Joy Lucas
  • 61
  • 1
  • 10
0
votes
1 answer

Swift: executing commands upon contact between nodes

Right now, I have a brick that falls down the screen. When it hits my square nothing happens. As you can see in the image below, I have four triangles that make up a square in the same spot, but with a low opacity. This is to help differentiate…
0
votes
2 answers

Optional collision with SKPhysicsContactDelegate

Is it possible to cancel a collision before it happens in the space? Example: A and B is about to collide but A has a property so that the collision with B should not take place for the specific SKPhysicsContact. All other collisions in the space…
0
votes
0 answers

SpriteKit collision detection not working as expected

So I have this code inside my GameScene class (child of SKScene): physicsWorld.contactDelegate = self physicsWorld.gravity = CGVector(dx: 0, dy: -9.8) addChild(balloon) addChild(monkey) monkey.physicsBody = SKPhysicsBody(rectangleOf:…
Arjun
  • 358
  • 5
  • 14
0
votes
1 answer

How to fix SKPhysicsContactDelegate not being called

My sprites are supposed to contact each other and print to console, however, one goes behind the other and they do not actually touch. Needless to say, nothing is being printed to console. I've tried using many different "types" of if statements in…
AglaiaZ
  • 23
  • 1
  • 5
0
votes
1 answer

Error with SKPhysicsContactDelegate?

I am trying to program a game with Spritekit in Swift. The aim is to escape with his character oncoming rectangles. Now I've made a mistake with the SKPhysicsContactDelegate (didBegin ()) method, so the figure's contact with one of the rectangles is…
Xcode
  • 35
  • 5
0
votes
1 answer

In SpriteKit SKPhysicsContactDelegate contact is not detected

I am trying to program a game with Spritekit in Swift. The aim is to escape with his character oncoming rectangles. Now I've made a mistake with the SKPhysicsContactDelegate (didBegin ()) method, so the figure's contact with one of the rectangles is…
Xcode
  • 35
  • 5
0
votes
1 answer

Multiple Contacts Registering

Any help would be greatly appreciated. I am relatively new to this and just feel like I beginning to understand coding. My issue ----- I am having difficult trying to fix a problem with a SpriteKit tutorial that I have been enhancing as a way to…
Don Gula
  • 1
  • 2