One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

HasPhysicsBody

protocol · iOS 13.0+ · SDK 27.1

@MainActor @preconcurrency protocol HasPhysicsBody : HasCollision

An interface that enables physics simulations based on the rules of Newtonian mechanics.

Members (11)

method · iOS 13.0+

resetPhysicsTransform

Swift declaration
@MainActor @preconcurrency func resetPhysicsTransform(recursive: Bool = true)

Resets the position, orientation, and velocities of the simulated physics body. Call this method only for dynamic rigid bodies, with a ``PhysicsBodyComponent/mode`` of ``PhysicsBodyMode/dynamic``. This is the only kind of body that’s affected by physics simulations. For all others, modify the entity’s transform property directly. Conversely, directly modifying the transform of a dynamic body has no effect because the physics simulation overwrites it on every frame. - Parameters: - recursive: Apply the reset to all descendant entities.

method · iOS 13.0+ · Deprecated

resetPhysicsTransform

Swift declaration
@MainActor @preconcurrency func resetPhysicsTransform(_ transform: Transform, recursive: Bool = true)

Resets the position and velocities of the simulated physics body. Call this method to change the transform applied to a body by physics simulation. This only matters for dynamic rigid bodies, with a ``PhysicsBodyComponent/mode`` of ``PhysicsBodyMode/dynamic``. This is the only kind of body that’s affected by physics simulations. For all others, modify the entity’s ``HasTransform/transform`` property directly. Conversely, directly modifying the transform of a dynamic body has no effect because the physics simulation overwrites it on every frame. - Parameters: - transform: The new transform to inject into the dynamic physics simulation of the entity. - recursive: Apply the reset to child entities.

get · iOS 13.0+

physicsBody

Swift declaration
@MainActor @preconcurrency var physicsBody: PhysicsBodyComponent? { get set }

A component that is used for physics simulations of the model entity in accordance with the laws of Newtonian mechanics.

set · iOS 13.0+

physicsBody

Swift declaration
@MainActor @preconcurrency var physicsBody: PhysicsBodyComponent? { get set }

A component that is used for physics simulations of the model entity in accordance with the laws of Newtonian mechanics.

method · iOS 13.0+

applyImpulse

Swift declaration
@MainActor @preconcurrency func applyImpulse(_ impulse: SIMD3<Float>, at position: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Applies an impulse to the physics body at the specified position. - Parameters: - impulse: An impulse in newton seconds. - position: The position at which to apply the impulse. - referenceEntity: The reference entity that defines the coordinate space in which `position` and `impulse` are defined.

method · iOS 13.0+

applyLinearImpulse

Swift declaration
@MainActor @preconcurrency func applyLinearImpulse(_ impulse: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Applies an impulse to the physics body at its center of mass. - Parameters: - impulse: An impulse in newton seconds. - referenceEntity: The reference entity that defines the coordinate space in which `impulse` is defined.

method · iOS 13.0+

applyAngularImpulse

Swift declaration
@MainActor @preconcurrency func applyAngularImpulse(_ impulse: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Applies an angular (torque) impulse to the physics body at its center of mass. - Parameters: - impulse: An angular impulse in kilogram square meters per second. - referenceEntity: The reference entity that defines the coordinate space in which `impulse` is defined.

method · iOS 13.0+

clearForcesAndTorques

Swift declaration
@MainActor @preconcurrency func clearForcesAndTorques()

Clears all forces previously added to the physics body.

method · iOS 13.0+

addForce

Swift declaration
@MainActor @preconcurrency func addForce(_ force: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Applies a force to the physics body at its center of mass. The physics simulator applies the added force until the end of the frame interval. To continue exerting the force after that time, add the force again with another call to the method. Handle the ``SceneEvents/Update`` event to receive an indication of when the frame interval ends. For an app that renders at 60 frames per second (fps), this event occurs about once per 16 milliseconds. - Parameters: - force: A force in newtons. - referenceEntity: The reference entity that defines the coordinate space in which `force` is defined.

method · iOS 13.0+

addForce

Swift declaration
@MainActor @preconcurrency func addForce(_ force: SIMD3<Float>, at position: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Applies a force to the physics body at the specified position. The physics simulator applies the added force until the end of the frame interval. To continue exerting the force after that time, add the force again with another call to the method. Handle the ``SceneEvents/Update`` event to receive an indication of when the frame interval ends. For an app that renders at 60 frames per second (fps), this event occurs about once per 16 milliseconds. - Parameters: - force: A force in newtons. - position: The position at which to apply the force. - referenceEntity: The reference entity that defines the coordinate space in which `position` and `force` are defined.

method · iOS 13.0+

addTorque

Swift declaration
@MainActor @preconcurrency func addTorque(_ torque: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Applies a torque to the physics body at its center of mass. The physics simulator applies the added torque until the end of the frame interval. To continue exerting the torque after that time, add the torque again with another call to the method. Handle the ``SceneEvents/Update`` event to receive an indication of when the frame interval ends. For an app that renders at 60 frames per second (fps), this event occurs about once per 16 milliseconds. - Parameters: - torque: A torque in newton meters per radian. - referenceEntity: The reference entity that defines the coordinate space in which `torque` is defined.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →