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
5
votes
1 answer

didBeginContact passed PKPhyicsObject

I have a helper method which extends SKPhysicsContact extension SKPhysicsContact { /// - returns: `[SKPhysicsBody]` containing all the bodies that match `mask` func bodiesMatchingCategory(mask: UInt32) -> [SKPhysicsBody] { let…
Stephen Furlani
  • 6,794
  • 4
  • 31
  • 60
4
votes
2 answers

Spritkit : Detect collision while drawing line using finger

I am trying to detect collision contactPoint between existing line and line which user currently drawing using finger. Here is my code : let padding: CGFloat = 100 override func didMove(to view: SKView) { physicsWorld.contactDelegate = self …
Devang
  • 11,258
  • 13
  • 62
  • 100
3
votes
2 answers

extension for SKPhysicsContact crashing

I'm creating a game with SpriteKit, that has collision between 2 bodies. After setting up the bodies, I've implemented the didBegin(_contact:) moethod as shown below: func didBegin(_ contact: SKPhysicsContact) { if contact.bodyA.categoryBitMask…
Fayyouz
  • 682
  • 7
  • 18
3
votes
1 answer

How to set minimum collision angle for SKSpriteNode

How can I set a minimum collision angle for an SKSpriteNode object so that when it collides with any other sprite, its reversed angle is always greater than or equal to this angle - either negative or positive - ? My objective is to prevent deadlock…
Amani Elsaed
  • 1,558
  • 2
  • 21
  • 36
3
votes
1 answer

How to detect SKSpriteNode Contact but do not react?

I have two SKSpriteNode first Hero +(id)hero { NSMutableArray *walkFrames = [NSMutableArray array]; SKTextureAtlas *heroAnimatedAtlas = [SKTextureAtlas atlasNamed:@"HeroImages"]; int numImages =…
Varun Naharia
  • 5,318
  • 10
  • 50
  • 84
2
votes
1 answer

SKPhysicsContact Not Detecting categoryBitMask Collision

So I have my "Floor.swift" class below which is basically a bunch of walls. I have objects coming from the top of the screen and once the Floor and SKSpriteNodes collide, I'd like the SKSpriteNode to be removed. Below is my Floor class. import…
Dewan
  • 429
  • 3
  • 16
2
votes
2 answers

Best way to "eat" something in SpriteKit

By "eat" I mean: when sprite A (Mario) collides with sprite B (a coin) the collision is detected and the coin is removed from the scene; however, Mario's movement is not altered by the collision with the coin. At the moment I'm using…
modalmusic
  • 71
  • 4
2
votes
2 answers

Physics contacts in SpriteKit

Is it possible to explain how bitmasking works for just this simplistic situation: A big (blue) ball. Contact BitMask 0b0001 A medium (red) ball. Contact BitMask 0b0010 A small (white) ball. Contact BitMask 0b0100 They have no collisions…
Confused
  • 6,048
  • 6
  • 34
  • 75
2
votes
1 answer

SpriteKit: How to prevent two SKSpriteNodes from colliding (in Swift)

I am making a relatively simple game consisting of a player, obstacles, and coins. My goal is to have collisions between the obstacles and the player only, and for contact between the player and a coin to trigger didBeginContact. Here's some…
Jamman00
  • 173
  • 8
2
votes
1 answer

Swift/SpriteKit - Collisions and Objects

I have a class called Item, and inside there is an instance variable called itemNode which is of type SKSpriteNode. In my GameScene class, when I create an instance of Item I create a physics body that is given to the Item's itemNode. In my…
2
votes
2 answers

SPriteKit Handling collision behaviour from different Angles

I am working on game, in which i need different collision behaviours from different side, Suppose there is a character when it collide to any other obstacle from down side, it will behave differently. when it collide to any other obstacle or…
umer sufyan
  • 1,005
  • 1
  • 12
  • 22
1
vote
2 answers

Get class who extends SKSpriteNode in didBegin

I have a class named Ball who extends SKSpriteNode class: import SpriteKit class Ball: SKSpriteNode { var score: Int = 0 init([...]){ [...] } func setScore(score: Int){ self.score = score; } } In my…
Swifted
  • 13
  • 2
1
vote
1 answer

How to obtain one solid SKPhysicsBody or SKNode object from SKNodes with contact?

I'm trying to create a House Stack-like game (https://apps.apple.com/gb/app/house-stack/id1458713825?l) but having problem to assign physics mechanism. My main problem is to create a single object when Node drop and contact with others and move them…
1
vote
2 answers

collision not detected between SKSpitekit nodes

I am building a maze and I have added some SKSpritekit nodes for the walls and a dot for the player. however when the dot and the walls collide, there is no detection of collision. my code is as follows: import UIKit import SpriteKit import…
1
vote
1 answer

Resetting didBeginContact() ... or what the scene thinks is being contacted on Player Death?

I'm dealing with a bug I've really struggled with fixing, My game consists of a Player sprite that interacts with parts of a platform... a standard platformer. I set up my game by attaching thin physics blocks to a larger platform physics body (big…
Corey F
  • 621
  • 4
  • 14
1
2 3 4 5