Contents

SKFieldForceEvaluator

The definition for a custom block that processes a single physics body’s interaction with the field.

Declaration

typealias SKFieldForceEvaluator = (vector_float3, vector_float3, Float, Float, TimeInterval) -> vector_float3

Discussion

The block parameters are defined as follows:

position

The position of the physics body. The coordinates are assumed to be in the following order: x, y, z. In SpriteKit, the z coordinate is always 0.

velocity

The velocity of the physics body. The coordinates are assumed to be in the following order: dx, dy, dz. In SpriteKit, the dz coordinate is always 0.

mass

The mass of the physics body.

charge

The charge of the physics body.

time

The amount of time that has passed since the last time the simulation was executed.

Your block should perform any force calculations you are interested in and return the resulting force.

See Also

Creating Field Nodes