Creates a field that attracts or repels objects based on their electrical charge, velocity, and distance from the field’s axis.
- iOS 8.0+
- macOS 10.10+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 3.0+
A physics field object. To use the field in a scene, attach it to the
physics property of an
Use this field type to make objects behave differently from one another when they enter a region, or to make an object's behavior different from its mass based behavior. A magnetic field behaves according to the second part of the Lorentz force equation modeling real-world electromagnetic forces—the field applies a force determined by the cross product of an object’s velocity vector and the magnetic field vector at the object’s location, with magnitude proportional to the object’s electric charge.
By default, physics bodies and particle systems have no electric charge, so they are unaffected by electric and magnetic fields. Use the
charge property of a physics body or the
particle property of a particle system to add charge-based behavior.
When the field’s
strength value is positive (the default), the magnetic field vectors circulate counterclockwise relative to the field’s
direction vector. (That is, the magnetic field models a real-world magnetic field created by current in a wire oriented in the field’s direction.) To make field vectors circulate clockwise, set the field’s
strength property to a negative value.
falloff value for a magnetic field is
2, indicating that the field’s effect diminishes with the square of distance from its center.