Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Point Effector 2D reference

Explore the properties of the Point Effector 2D used to attract or repulse against a given source point.
Read time 3 minutesLast updated 14 days ago

The Point Effector 2D applies forces to attract/repulse against a source point which can be defined as the position of the rigid-body or the center of a collider used by the effector. When another (target) collider comes into contact with the effector then a force is applied to the target. Where the force is applied and how it is calculated can be controlled.
Colliders that you use with the effector would typically be set as triggers so that other colliders can overlap with it to have forces applied however, non-triggers will still work but forces will only be applied when colliders come into contact with it.

Properties

Property

Function

Use Collider MaskEnable to use the Collider Mask property. If disabled, then the global collision matrix will be used as is the default for all colliders.
Collider MaskThe mask used to select specific layers allowed to interact with the effector.
Force MagnitudeThe magnitude of the force to be applied.
Force VariationThe variation of the magnitude of the force to be applied.
Distance ScaleThe scale applied to the distance between the source and target. When calculating the distance, it is scaled by this amount allowing the effective distance to be changed which controls the magnitude of the force applied.
Linear DampingThe linear drag to apply to rigid-bodies.
Angular DampingThe angular drag to apply to rigid-bodies.
Force SourceThe force source is the point that attracts or repels target objects. The distance from the target is defined from this point. The options are the following:
  • Collider: The source point is defined as the current position of the collider.
  • Rigidbody: The source point is defined as the current position of the rigidbody.
Force TargetThe force target is the point on a target object where the effector applies any force. The distance to the source is defined from this point. The options are the following:
  • Collider: The target point is defined as the current position of the collider. Applying force here can generate torque (cause the target to rotate) if the collider isn't positioned at the center of mass.
  • Rigidbody: The target point is defined as the current center-of-mass of the rigidbody. Applying force here will never generate torque (cause the target to rotate).
Force ModeHow the force is calculated. The options are the following:
  • Constant: The same force is applied however far apart the source and target are.
  • Inverse Linear: The force is applied as a function of the inverse-linear distance between the source and target. When the source and target are in the same position, then the full force is applied, but it falls off linearly as they move apart.
  • Inverse Squared: The force is applied as a function of the inverse-squared distance between the source and target. When the source and target are in the same position, then the full force is applied, but it falls off squared as they move apart. This is similar to real-world gravity.