# LineForce

Show Deprecated

A LineForce is used to apply a force along a line between two points. As the end points of the line move, the direction of the force will change accordingly. ## Direction of force

The direction that a LineForce applies its force in is determined by its attachments and LineForce.ApplyAtCenterOfMass properties. When ApplyAtCenter of mass is false, which it is by default, the direction of the force will be from the location of Attachment0 to the location of Attachment1. If ApplyToCenter is true, then the direction will be from the center of mass of Attachment0's parent to the location of Attachment1. Note that if the parent of Attachment0 is rigidly connected to other parts, then the LineForce will use the center of mass of all of the parts to determine the origin of the direction.

## Location of force

A LineForce will apply its force on the Parent of its Attachment0, but the location where the force is applied is determined by the LineForce's ApplyAtCenterOfMass property.

When ApplyAtCenterOfMass is false, which it is by default, the force will be applied to the part at the Attachement0's location. This means that if the attachment is not at the center of the part, it can create a torque on the part.

When ApplyAtCenterOfMass is set to true, the force will check if any other parts are rigidly connected to the parent part of its Attachment0. If there are, then the force will apply at the center of mass of all of the connected parts. If there are no rigid connections to other parts, the force will simply be applied at the center of mass of the part.

## Strength of Force

The strength of the force applied by a LineForce is determined by the LineForce.Magnitude and LineForce.InverseSquareLaw properties. The InverseSquareLaw property determines whether the force is constant or not.

When InverseSquareLaw is false, which is is by default, the force applied is constant, and its magnitude is equal to the magnitude defined by the Magnitude property.

When InverseSquareLaw is true, then the force will scale based on how much distance there is between the two endpoints. When the distance is 1 stud, then the force's magnitude will be the value of the Magnitude property. If the two points are further away, the force will decrease. Conversely, the force will increase if the two points move closer together. This function can be used to determine the force at any given separation:

``ActualMagnitude = Magnitude / (Separation ^ 2)``

LineForces with LineForce.InverseSquareLaw set to true can be used to simulate various physical systems such as gravity or electric fields.

## Summary

### Properties

When set to false, the force will be applied to the part at the Attachment0's location. This means that if the attachment is not at the center of the part, it can create a torque on the part.

When true, the force magnitude is multiplied by the inverse square of the distance.

The magnitude of the force.

Maximum absolute force that can be applied.

Enables an equal and opposite reaction force on the parent of Attachment1.

## Properties

### ApplyAtCenterOfMass

When true, applies force at center of mass of Attachment0's parent Part, and the line determining the direction of the force will start at the said center of mass. When false, the force is applied at Attachment0's location and the line determining the direction will also start at Attachment0.

### InverseSquareLaw

When true, the force magnitude is multiplied by the inverse square of the distance.

### Magnitude

The magnitude of the force.

### MaxForce

The maximum absolute force that can be applied. This property is enabled only when InverseSquareLaw is also enabled. This property is mainly used to address the issue that the force of the body mover becomes infinite the closer the two attachments are, causing explosions that can't be prevented by scripts. This property bounds the force's absolute value.

### ReactionForceEnabled

Enables a reaction force (equal an opposite) to be applied to the parent of Attachment1. By default line force only applies a force on the parent of Attachment0 and uses Attachment1 as the target direction without any dynamic relationship.