Adds a behavior to the physics world.
SDKs
- iOS 8.0+
- macOS 10.10+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 3.0+
Framework
- Scene
Kit
Declaration
func addBehavior(_ behavior: SCNPhysics Behavior)
Parameters
behavior
The behavior to be added.
Discussion
Physics behaviors constrain or modify the effects of the physics simulation on sets of physics bodies. For example, the SCNPhysics
behavior causes two bodies to move as if connected by a hinge that pivots around a specific axis, and the SCNPhysics
behavior causes a body to roll like a car or other wheeled vehicle.
To use a behavior in your scene, follow these steps:
Create
SCNPhysics
objects and attach them to each node that participates in the behavior.Body Create and configure a behavior object joining the physics bodies. See
SCNPhysics
for a list of behavior classes.Behavior Call
add
on your scene’s physics world object to add the behavior to the physics simulation.Behavior(_:)