SCNPhysicsBehavior
The abstract superclass for joints, vehicle simulations, and other high-level behaviors that incorporate multiple physics bodies.
Declaration
class SCNPhysicsBehaviorOverview
An SCNPhysicsBehavior object defines a high-level behavior for one or more physics bodies, modifying the results of the physics simulation. Behaviors include joints that connect multiple bodies so they move together and vehicle definitions that cause a body to roll like a car. You never use this class directly; instead, you instantiate one of the subclasses that defines the kind of behavior you want to add to your physics world. describes the kinds of behaviors you can create in SceneKit.
Class Name | Description |
|---|---|
Connects two bodies and allows them to pivot around each other on a single axis. | |
Connects two bodies and allows them to pivot around each other in any direction. | |
Connects two bodies and allows them to slide or rotate relative to one another. Slider joints can also work as motors, applying a force or torque between the two bodies. | |
Simulates a physics body as the chassis of a car or other wheeled vehicle. You control a vehicle in terms of steering, braking, and acceleration, and use Scnphysicsvehiclewheel objects to define the appearance and physical properties of each of its wheels. |
To use a physics behavior, you follow these steps:
Create SCNPhysicsBody objects and attach them to each node that participates in the behavior.
Create and configure a behavior object using one of the subclasses listed in Table 1.
Add the behavior to the physics simulation by calling the addBehavior(_:) method on your scene’s SCNPhysicsWorld object.