<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKPhysicsContactDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(pl)SKPhysicsContactDelegate"
  },
  "title" : "SKPhysicsContactDelegate"
}
-->

# SKPhysicsContactDelegate

Methods your app can implement to respond when physics bodies come into contact.

```
protocol SKPhysicsContactDelegate : NSObjectProtocol
```

## Overview

An object that implements the [`SKPhysicsContactDelegate`](/documentation/SpriteKit/SKPhysicsContactDelegate) protocol can respond when two physics bodies with overlapping [`contactTestBitMask`](/documentation/SpriteKit/SKPhysicsBody/contactTestBitMask) values are in contact with each other in a physics world. To receive contact messages, you set the [`contactDelegate`](/documentation/SpriteKit/SKPhysicsWorld/contactDelegate) property of a [`SKPhysicsWorld`](/documentation/SpriteKit/SKPhysicsWorld) object. The delegate is called when a contact starts or ends.

> Important:
> The physics contact delegate methods are called during the physics simulation step. During that time, the physics world can’t be modified and the behavior of any changes to the physics bodies in the simulation is undefined. If you need to make such changes, set a flag inside ``doc://com.apple.spritekit/documentation/SpriteKit/SKPhysicsContactDelegate/didBegin(_:)`` or ``doc://com.apple.spritekit/documentation/SpriteKit/SKPhysicsContactDelegate/didEnd(_:)`` and make changes in response to that flag in the ``doc://com.apple.spritekit/documentation/SpriteKit/SKSceneDelegate/update(_:for:)`` method in a ``doc://com.apple.spritekit/documentation/SpriteKit/SKSceneDelegate``.

You can use the contact delegate to play a sound or execute game logic, such as increasing a player’s score, when a contact event occurs. The following code shows how to display a shockwave effect when two nodes with the name `ball` come into contact. The code only creates the effect when the collision impulse is above a specified threshold:

Listing 1. Creating a shockwave effect when objects come into contact

```swift
let shockWaveAction: SKAction = {
    let growAndFadeAction = SKAction.group([SKAction.scale(to: 50, duration: 0.5),
                                            SKAction.fadeOut(withDuration: 0.5)])
    
    let sequence = SKAction.sequence([growAndFadeAction,
                                      SKAction.removeFromParent()])
    
    return sequence
}()

func didBegin(_ contact: SKPhysicsContact) {
    if contact.collisionImpulse > 5 &&
        contact.bodyA.node?.name == "ball" &&
        contact.bodyB.node?.name == "ball" {
        
        let shockwave = SKShapeNode(circleOfRadius: 1)

        shockwave.position = contact.contactPoint
        scene.addChild(shockwave)
        
        shockwave.run(shockWaveAction)
    }
}
```

## Topics

### Responding to Contact Events

[`didBegin(_:)`](/documentation/SpriteKit/SKPhysicsContactDelegate/didBegin(_:))

Called when two bodies first contact each other.

[`didEnd(_:)`](/documentation/SpriteKit/SKPhysicsContactDelegate/didEnd(_:))

Called when the contact ends between two physics bodies.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)