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

# SKPhysicsWorld

The driver of the physics engine in a scene; it exposes the ability for you to configure and query the physics system.

```
class SKPhysicsWorld
```

## Overview

`SKPhysicsWorld` runs the physics engine of a scene and is the place that contact detection occurs. Do not create a `SKPhysicsWorld` directly; the system creates a physics world and adds it to the scene’s [`physicsWorld`](/documentation/SpriteKit/SKScene/physicsWorld) property.

The physics world allows you to:

- Set important properties like [`gravity`](/documentation/SpriteKit/SKPhysicsWorld/gravity)
- Join two physics bodies using an [`SKPhysicsJoint`](/documentation/SpriteKit/SKPhysicsJoint)
- Respond to collision between two physics bodies using [`contactDelegate`](/documentation/SpriteKit/SKPhysicsWorld/contactDelegate)
- Do custom collisions detection or hit testing

## Topics

### Configuring the Physics World

[`gravity`](/documentation/SpriteKit/SKPhysicsWorld/gravity)

A vector that specifies the gravitational acceleration applied to physics bodies in the physics world.

[`speed`](/documentation/SpriteKit/SKPhysicsWorld/speed)

The rate at which the simulation executes.

### Joining Physics Bodies with Joints

[`add(_:)`](/documentation/SpriteKit/SKPhysicsWorld/add(_:))

Adds a joint to the physics world.

[`removeAllJoints()`](/documentation/SpriteKit/SKPhysicsWorld/removeAllJoints())

Removes all joints from the physics world.

[`remove(_:)`](/documentation/SpriteKit/SKPhysicsWorld/remove(_:))

Removes a specific joint from the physics world.

### Detecting Collisions

[`contactDelegate`](/documentation/SpriteKit/SKPhysicsWorld/contactDelegate)

A delegate that is called when two physics bodies come in contact with each other.

### Searching the Scene for Physics Bodies

[Searching the World for Physics Bodies](/documentation/SpriteKit/searching-the-world-for-physics-bodies)

Cast a ray to find the physics bodies in the scene that intersect it.

[`body(alongRayStart:end:)`](/documentation/SpriteKit/SKPhysicsWorld/body(alongRayStart:end:))

Searches for the first physics body that intersects a ray.

[`body(at:)`](/documentation/SpriteKit/SKPhysicsWorld/body(at:))

Searches for the first physics body that contains a point.

[`body(in:)`](/documentation/SpriteKit/SKPhysicsWorld/body(in:))

Searches for the first physics body that intersects the specified rectangle.

[`enumerateBodies(alongRayStart:end:using:)`](/documentation/SpriteKit/SKPhysicsWorld/enumerateBodies(alongRayStart:end:using:))

Enumerates all the physics bodies in the scene that intersect a ray.

[`enumerateBodies(at:using:)`](/documentation/SpriteKit/SKPhysicsWorld/enumerateBodies(at:using:))

Enumerates all the physics bodies in the scene that contain a point.

[`enumerateBodies(in:using:)`](/documentation/SpriteKit/SKPhysicsWorld/enumerateBodies(in:using:))

Enumerates all the physics bodies in the scene that intersect the specified rectangle.

### Sampling Physics Fields

[`sampleFields(at:)`](/documentation/SpriteKit/SKPhysicsWorld/sampleFields(at:))

Samples all of the field nodes in the scene and returns the summation of their forces at that point.



---

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)