Contents

magneticField()

Creates a field node that applies a magnetic force based on the velocity and electrical charge of the physics bodies.

Declaration

class func magneticField() -> SKFieldNode

Return Value

A new magnetic field node.

Discussion

The force generated by this field is directed on a line that is determined by calculating the cross-product between the direction of the the physics body’s velocity property and a line traced between the field node and the physics body. This field models the second part of the Lorentz equation:

F = qvB

Where F equals force, q equals charge, v equals velocity, B equals magnetic field and E equals electric field.

The force has a magnitude proportional to the field’s strength property and the physics body’s charge and velocity properties. Therefore, physics bodies that are either stationary or with a charge of zero will not be affected by a magnetic field. Magnetic fields with a negative strength value impart a clockwise spin on the physics bodies they affect, while a positive strength give a clockwise spin.The falloff property of a magnetic field node is set by default to 2.

See Also

Creating Field Nodes