Platforms to show: All Mac Windows Linux Cross-Platform

Back to SCNPhysicsBodyMBS class.

SCNPhysicsBodyMBS.applyForce(direction as SCNVector3MBS, atPosition as SCNVector3MBS, impulse as Boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SceneKit MBS Mac64bit Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Applies a force or impulse to the body at a specific point.

direction: The direction and magnitude of the force (in newtons) or of the impulse (in newton-seconds).
position: The point on the body where the force or impulse should be applied, in the local coordinate system of the SCNNodeMBS object containing the physics body.
impulse: True to apply an instantaneous change in momentum; false to apply a force that affects the body at the end of the simulation step.

Applying a force or impulse to a body at a position other than its center of mass may impart both linear and angular acceleration, depending on how the body is situated in the physics world and the other forces acting upon it.
The impulse parameter determines how this method contributes to the physics simulation:

  • If you specify true, SceneKit treats the direction parameter as an impulse, measured in newton-seconds, and accelerates the physics body immediately. Use this option to simulate instantaneous effects such as launching a projectile.
  • If you specify false, SceneKit treats the direction parameter as a force, measured in newtons. At the end of each simulation step (by default, a step occurs once for each frame in the rendering loop), SceneKit sums all forces applied to the physics body during that step and accelerates the body according to the net effect of those forces. Use this option when you want to simulate continuous forces on the body by calling applyForce on each simulation step.

Note
The impulse parameter effectively changes the unit of magnitude. A value that results in a certain acceleration when applied continuously on each frame of the simulation results in much less acceleration if applied only during a single frame.

As with all physical quantities in SceneKit, you need not use realistic force measurements in your app—the effects of the physics simulation depend on the relative differences between forces, not on their absolute values. You may use whatever values produce the behavior or gameplay you’re looking for as long as you use them consistently.

See also:

Some examples using this method:

SCNPhysicsBodyMBS.applyForce(direction as SCNVector3MBS, impulse as Boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SceneKit MBS Mac64bit Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Applies a force or impulse to the body at its center of mass.

direction: The direction and magnitude of the force (in newtons) or of the impulse (in newton-seconds).
impulse: True to apply an instantaneous change in momentum; false to apply a force that affects the body at the end of the simulation step.

Applying a force or impulse to a body imparts a linear acceleration proportional to its mass.
The impulse parameter determines how this method contributes to the physics simulation:

  • If you specify true, SceneKit treats the direction parameter as an impulse, measured in newton-seconds, and accelerates the physics body immediately. Use this option to simulate instantaneous effects such as launching a projectile.
  • If you specify false, SceneKit treats the direction parameter as a force, measured in newtons. At the end of each simulation step (by default, a step occurs once for each frame in the rendering loop), SceneKit sums all forces applied to the physics body during that step and accelerates the body according to the net effect of those forces. Use this option when you want to simulate continuous forces on the body by calling applyForce:impulse: on each simulation step.

Note
The impulse parameter effectively changes the unit of magnitude. A value that results in a certain acceleration when applied continuously on each frame of the simulation results in much less acceleration if applied only during a single frame.

As with all physical quantities in SceneKit, you need not use realistic force measurements in your app—the effects of the physics simulation depend on the relative differences between forces, not on their absolute values. You may use whatever values produce the behavior or gameplay you’re looking for as long as you use them consistently.

See also:

SCNPhysicsBodyMBS.applyTorque(torque as SCNVector4MBS, impulse as Boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SceneKit MBS Mac64bit Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Applies a net torque or a change in angular momentum to the body.

torque: The direction and magnitude of the torque (in newton-meters) or of the change of angular momentum (in newton-meter-seconds), relative to the world coordinate space of the scene.
impulse: True to apply an instantaneous change in angular momentum; false to apply a torque that affects the body at the end of the simulation step.

Applying a torque to a body changes its angular velocity by an amount related to its mass and shape, rotating it without affecting its linear acceleration. Each component of the torque vector relates to rotation about the corresponding axis in the local coordinate system of the SCNNode object containing the physics body. For example, applying a torque of {0.0, 0.0, 1.0} causes a node to spin counterclockwise around the world-space z-axis.
The impulse parameter determines how this method contributes to the physics simulation:

  • If you specify true, SceneKit treats the direction parameter as an instantaneous change in angular momentum, measured in newton-meter-seconds.
  • If you specify false, SceneKit treats the direction parameter as a torque, measured in newton-meters. At the end of each simulation step (by default, a step occurs once for each frame in the rendering loop), SceneKit sums all forces and torques applied to the physics body during that step and accelerates the body according to the net effect of those forces and torques. Use this option when you want to simulate gradual acceleration by calling applyTorque:impulse: on each simulation step.

Note
The impulse parameter effectively changes the unit of magnitude. A value that results in a certain acceleration when applied continuously on each frame of the simulation results in much less acceleration if applied only during a single frame.

As with all physical quantities in SceneKit, you need not use realistic force and torque measurements in your app—the effects of the physics simulation depend on the relative differences between forces, not on their absolute values. You may use whatever values produce the behavior or gameplay you’re looking for as long as you use them consistently.

SCNPhysicsBodyMBS.clearAllForces

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SceneKit MBS Mac64bit Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Cancels all continuous forces and torques acting on the physics body during the current simulation step.

When you pass false for the impulse parameter in the applyForce, applyForce:atPosition, or applyTorque method, SceneKit waits until the end of the current simulation step before applying its effect. At that time, SceneKit sums all forces and torques applied during that simulation step and changes the velocity or angular velocity of the body according to the net effect of those forces and torques.
Call clearAllForces to cancel any forces and torques previously applied during the current simulation step.

SCNPhysicsBodyMBS.Constructor(type as Integer, shape as SCNPhysicsShapeMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SceneKit MBS Mac64bit Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Creates a physics body with the specified type and shape.

type: A constant that determines how a body responds to forces and collisions. See SCNPhysicsBodyType.
shape: A physics shape defining the volume of the body for collision detection purposes.

Returns a new physics body object.

For the body to participate in collision detection or respond to forces, you must attach it to the physicsBody property of an SCNNode object in a scene.
If you pass nil for the shape parameter, SceneKit automatically creates a physics shape for the body when you attach it to a node, based on that node’s geometry property. To create a physics shape that’s based on the geometries of a node and its hierarchy of children, or to control the level of detail in a physics shape, create the physics shape manually using an SCNPhysicsShape class method.

Note
For nodes containing custom geometry, the physics shape SceneKit automatically creates is a rough approximation of the geometry. This approximation, or convex hull, provides a compromise between accuracy and performance in collision detection. For the best collision detection performance, create an SCNPhysicsShape instance based on a basic geometry class (SCNBox, SCNSphere, SCNPyramid, SCNCone, SCNCylinder, or SCNCapsule).

SCNPhysicsBodyMBS.copy as SCNPhysicsBodyMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SceneKit MBS Mac64bit Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Creates a copy of the body.

SCNPhysicsBodyMBS.resetTransform

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SceneKit MBS Mac64bit Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Updates the position and orientation of a body in the physics simulation to match that of the node to which the body is attached.

If you change the position or orientation of a node with an attached static or dynamic physics body, call this method afterward to ensure that the physics simulation incorporates the change. You need not call this method for kinematic bodies.
Note that dynamic and physics bodies are designed to be moved only by the physics simulation or not at all. You may use this method to move them regardless of this restriction, but at a cost to performance.

The items on this page are in the following plugins: MBS Mac64bit Plugin.


The biggest plugin in space...