Class

SCNPhysicsWorld

The global simulation of collisions, gravity, joints, and other physics effects in a scene.

Declaration

@interface SCNPhysicsWorld : NSObject

Overview

You do not create SCNPhysicsWorld objects directly; instead, read the physicsWorld property of an SCNScene object. Use physics world object to perform the following tasks:

  • Manage global properties of the simulation, such as its speed and constant gravity. (For more precise control of gravity and similar effects, see the SCNPhysicsField class.)

  • Register behaviors that modify interactions between the scene’s physics bodies, such as joints and vehicles. For more details, see SCNPhysicsBehavior.

  • Specify a delegate object to receive messages when two physics bodies contact each other

  • Perform specific contact tests, and search for physics bodies in the scene using ray and sweep tests.

Topics

Managing the Physics Simulation

gravity

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

speed

The rate at which the simulation executes.

timeStep

The time interval between updates to the physics simulation.

- updateCollisionPairs

Forces the physics engine to reevaluate possible collisions between physics bodies.

Registering Physics Behaviors

- addBehavior:

Adds a behavior to the physics world.

- removeBehavior:

Removes a behavior from the physics world.

allBehaviors

The list of behaviors affecting bodies in the physics world.

- removeAllBehaviors

Removes all behaviors affecting bodies in the physics world.

Detecting Contacts Between Physics Bodies

contactDelegate

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

- contactTestBetweenBody:andBody:options:

Checks for contacts between two physics bodies.

- contactTestWithBody:options:

Checks for contacts between one physics body and any other bodies in the physics world.

Searching for Physics Bodies

- rayTestWithSegmentFromPoint:toPoint:options:

Searches for physics bodies along a line segment between two points in the physics world.

- convexSweepTestWithShape:fromTransform:toTransform:options:

Searches for physics bodies in the space formed by moving a convex shape through the physics world.

Search Options

SCNPhysicsTestOption

Keys in options dictionaries that affect how SceneKit searches for bodies in a collision, ray, or sweep test.

Relationships

Inherits From

Conforms To

See Also

Physics in a Scene

SCNPhysicsField

An object that applies forces, such as gravitation, electromagnetism, and turbulence, to physics bodies within a certain area of effect.

SCNPhysicsBehavior

The abstract superclass for joints, vehicle simulations, and other high-level behaviors that incorporate multiple physics bodies.