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

Creating custom contact delegates with Xamarin SpriteKit in C#

I would like to override the didBeginContact function so as to implement custom logic when two physics objects in my scene collide. I understand how this would be done in Swift by first setting the contact delegate to be the scene object itself and…
0
votes
1 answer

collision between two sprites not working

I Cannot seem to get the 2 sprites to make contact with one another, as when the app runs one of the sprites does not make contact but just goes pass it. I'm not sure whats wrong. Could someone please help me. import SpriteKit import…
0
votes
2 answers

SpriteKit crash: how can physics body lose association with SKNode?

This code crashes because secondBody is not associated with a node. func didBegin(_ contact: SKPhysicsContact) { // Set vars to hold bodies var firstBody: SKPhysicsBody var secondBody: SKPhysicsBody // Sort bodies if…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
0
votes
1 answer

Swift 3 SpriteKit Detecting Contacts

I'm new to swift and I have been trying to figure out how to use bitmasks and didBegin(_ contact: SKPhysicsContact) to detect when two spaceships touch each other. I can't seem to figure out how. Here is what I have so far: import SpriteKit import…
GS.
  • 123
  • 12
0
votes
1 answer

How do I detect the collision of two SKShapeNodes in Swift without affecting their physics?

Log: Here Please excuse me if this is a stupid, horrid question, but I have been stuck on it and can't find answers anywhere. I have a few nodes: leftMaze, rightMaze, and player. I am trying to detect when the player collides with any of the other…
0
votes
1 answer

SKSpritNode no contact with other bodies?

I would like to create a game with multiple contact options but I need to find also condition when sprite is not with contact with any other body. I don't want to be informed that sprite is losing contact like with didEnd function. I need…
mamaz
  • 1
  • 5
0
votes
0 answers

Contact test bitmask not working

I've created 2 nodes but when they contact nothing happens, here's the code: private var circle:Circle? circle?.name = "Ball" circle?.physicsBody?.isDynamic = true circle?.physicsBody?.categoryBitMask = 1 …
0
votes
2 answers

SKPhysicsContact body, can't change properties

I have a SpriteKit physics contact firing in didBegin(contact:). I grab the physics body for the instance of the Dot object that I want to move offscreen, but when I try to change its position like so, nothing happens: First Approach /* In…
peacetype
  • 1,928
  • 3
  • 29
  • 49
0
votes
2 answers

Is there a way to write a test of a `SKPhysicsContactDelegate` functions?

Can I mock SKPhysicsContact object to feed into -(void)didEndContact:(SKPhysicsContact *)contact method? Or is there any other technique, that can be leveraged here? class PhysicsTestCase: XCTestCase { var physics: GamePhysics! ... …
Zapko
  • 2,461
  • 25
  • 30
0
votes
1 answer

SpriteKit didEndContact not being called

In my didEndContact: method I increment a "currentScore". For some reason, didEndContact: is not being called, and hence the "currentScore" is not being incremented. Any ideas why or what I should be looking for to debug this? func…
SRMR
  • 3,064
  • 6
  • 31
  • 59
0
votes
0 answers

SKPhysicsContact.CollisionImpulse value seems inconsistent

I'm creating a game where a player navigates their vessel (SKSpriteNode A) and tries to make contact with a stationary rectangular sprite that is slowly rotating (SKSpriteNode B). They can navigate their vessel via impulses to speed up, slow down,…
user1392961
0
votes
1 answer

Changing the location of a node once the location is already set.(SpriteKit)

I am working on a game that involves objects(fish) that move across the screen that you need to catch with another object(hook) that you can move up and down. Once the objects make contact the fish's position is supposed to become the same as the…
james
  • 69
  • 5
0
votes
1 answer

Describe SKPhysicsContact object (attributes and methods)

I know (I think at least) that when two sprites collide, the didBeginContact method defined in the SKPhysicsConstactDelegate will be called with SKPhysicsContact as a parameter. What are the methods and attributes associated with the…
SuperCow
  • 1,523
  • 7
  • 20
  • 32
0
votes
0 answers

Is there a way to stop an animation just before contact between bodies in spritKit ?

I have a SpriteKit animation where two bodies enter in contact at high speed. Unfortunatly if I use the didBeginContact Method, the two bodies are already overlapping a little when I stop the animation. I would like to stop the animation before the…
0
votes
0 answers

Simulator vs Device Contact Point Conversion Differences?

I have been struggling with this for a while now and cant seem to find the issue. I have an SKScene which i will refer to as self, and an SKNode that is called chapterScene that gets added to self. I have a boundary set up that contains a movable…