Instance Method

addTorque(_:relativeTo:)

Applies a torque to the physics body at its center of mass.

Declaration

func addTorque(_ torque: SIMD3<Float>, relativeTo referenceEntity: Entity?)

Parameters

torque

A torque in newton meters per radian.

referenceEntity

The reference entity that defines the coordinate space in which torque is defined.

Discussion

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.

See Also

Simulating Forces and Impulses

var physicsBody: PhysicsBodyComponent?

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

struct PhysicsBodyComponent

A component that defines an entity’s behavior in physics body simulations.

func addForce(SIMD3<Float>, relativeTo: Entity?)

Applies a force to the physics body at its center of mass.

func addForce(SIMD3<Float>, at: SIMD3<Float>, relativeTo: Entity?)

Applies a force to the physics body at the specified position.

func clearForcesAndTorques()

Clears all forces previously added to the physics body.

func applyLinearImpulse(SIMD3<Float>, relativeTo: Entity?)

Applies an impulse to the physics body at its center of mass.

func applyAngularImpulse(SIMD3<Float>, relativeTo: Entity?)

Applies an angular (torque) impulse to the physics body at its center of mass.

func applyImpulse(SIMD3<Float>, at: SIMD3<Float>, relativeTo: Entity?)

Applies an impulse to the physics body at the specified position.

func resetPhysicsTransform(recursive: Bool)

Resets the position, orientation, and velocities of the simulated physics body.

func resetPhysicsTransform(Transform, recursive: Bool)

Resets the position and velocities of the simulated physics body.

Deprecated
protocol HasPhysicsBody

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