Class

SCNPhysicsField

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

Declaration

@interface SCNPhysicsField : NSObject

Overview

You can create many types of field effects, such as gravitation, electromagnetism, and turbulence. To add a field effect to a scene, you create a physics field of the type you want to use and then attach it to the physicsField property of a node in the scene.

Physics fields can affect both SCNPhysicsBody objects and the particles spawned by SCNParticleSystem objects.

Topics

Creating Physics Fields

+ dragField

Creates a field that slows any object in its area of effect with a force proportional to the object’s velocity.

+ vortexField

Creates a field whose forces circulate around an axis.

+ radialGravityField

Creates a field that accelerates objects toward its center.

+ linearGravityField

Creates a field that accelerates objects in a specific direction.

+ noiseFieldWithSmoothness:animationSpeed:

Creates a field that applies random forces to objects in its area of effect.

+ turbulenceFieldWithSmoothness:animationSpeed:

Creates a field that applies random forces to objects in its area of effect, with magnitudes proportional to those objects’ velocities.

+ springField

Creates a field that pulls objects toward its center with a spring-like force.

+ electricField

Creates a field that attracts or repels objects based on their electrical charge and on their distance from the field’s center.

+ magneticField

Creates a field that attracts or repels objects based on their electrical charge, velocity, and distance from the field’s axis.

Creating Custom Physics Fields

+ customFieldWithEvaluationBlock:

Creates a field that runs the specified block to determine the force a field applies to each object in its area of effect.

Specifying a Field’s Area of Effect

halfExtent

A location marking the end of the field’s area of effect.

scope

The area affected by the field, either inside or outside its region.

usesEllipsoidalExtent

A Boolean value that determines whether the field’s area of effect is shaped like a box or ellipsoid.

offset

The offset of the field’s center within its area of effect.

direction

The field’s directional axis.

Specifying a Field’s Behavior

strength

A multiplier for the force that the field applies to objects in its area of effect.

falloffExponent

An exponent that determines how the field’s strength diminishes with distance.

minimumDistance

The minimum value for distance-based effects.

active

A Boolean value that determines whether the field’s effect is enabled.

exclusive

A Boolean value that determines whether the field overrides other fields whose areas of effect it overlaps.

Choosing Physics Bodies to Be Affected by the Field

categoryBitMask

A mask that defines which categories this physics field belongs to.

Constants

SCNFieldForceEvaluator

The signature for a block that SceneKit calls to determine the effect of a custom field on an object.

SCNPhysicsFieldScope

Options for defining the region of space affected by a physics field, used by the scope property.

Relationships

Inherits From

See Also

Physics in a Scene

SCNPhysicsWorld

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

SCNPhysicsBehavior

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