New Body Movers

Hey everyone!

As you may or may not have known, the good folks on our Physics team have been working on a revamp of the body movers system. These new movers take advantage of the attachment/constraint system and all of the other optimizations we have been making under the hood.

To help you get started, we’ve created a sample place showcasing the new movers in various configurations. While we tried to cover a lot of simple cases, this merely scratches the surface of what you can do, so don’t be afraid to experiment! You can get a copy of the place here: New Body Movers Example.rbxl (17.6 KB)

#Documentation

One of the goals of the new movers was to allow you to recreate behaviors that you had with the old movers, along with some cool new features that were hard or simply impossible with the old system. We have some initial documentation of all the members of the new Instances that we will lists below, but for a quick reference if you want to see how old behavior can be mapped to new:

  • BodyForce > VectorForce (relative to World)
  • BodyThrust > VectorForce (relative to Attachment0)
  • BodyAngularVelocity > Torque (only for torque. Use actuated hinge to reach specific rotational velocity)
  • BodyGyro > AlignOrientation
  • BodyPosition > AlignPosition
  • RocketPropulsion > AlignOrientation + AlignPosition/VectorForce
  • (No legacy mover) > LineForce

##Vector Force
A VectorForce is used to apply a force to a part or assembly of parts. The direction and strength of the force is determined by a Vector3 and can be relative to an attachment on the part, another attachment, or the world coordinate system.

###Location of Force
A VectorForce will apply its force on the Parent of its Attachment0, but the location where the force is applied is determined by the VectorForce’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.
###Direction of Force
The direction of the force is determined by the Vector3 defined by force, but it will also be affected by the RelativeTo property.

By default, RelativeTo is set to Attachment0, meaning the force will be applied in the space local to the attachment. Remember that when visualizing an attachment, the yellow arrow shows the direction of positive X, and the orange bar shows the direction of positive Y. If the part the attachment is connected to rotates, the force will change direction to make sure it is still in the context of the attachment.

RelativeTo can also be set to Attachment1. In this case, the force will be applied in the space local to Attachment1, regardless of the orientation of Attachment0 or its connected part. If Attachment1 rotates, then the force will change to stay oriented correctly.

Last, RelativeTo can also be set to World. In this mode, the force is applied in world coordinates, regardless of the orientation of Attachment0 or its part.
###Properties

  • Enabled (bool) - Determines whether the VectorForce is active or not.
  • ApplyAtCenterOfMass (bool) - When true, applies force at center of mass of Attachment0’s parent Part. When false, applied at Attachment0.
  • Force (Vector3) - The strength and direction of the force.
  • RelativeTo (enum - Attachment0, Attachment1, World) - The coordinate frame in which the Force is expressed.
  • Attachment0 (Attachment) - The base attachment. The parent of this attachment is the part that will be affected by the force.
  • Attachment1 (Attachment) - The attachment to use for the reference frame if RelativeTo is equal to Attachment1. Note that this only determines the direction of the attachment. The force will still be applied to Attachment0. If RelativeTo is not equal to Attachment1 then this property is not used.

##Line Force
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 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 false, 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 VectorForce will apply its force on the Parent of its Attachment0, but the location where the force is applied is determined by the VectorForce’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 VectorForce is determined by the VectorForce’s Magnitude and 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)

Tip: VectorForces with InverseSquareLaw set to true can be used to simulate various physical systems such as gravity or electric fields.
###Properties

  • Enabled (bool) - Determines whether the LineForce is active or not.
  • ApplyAtCenterOfMass (bool) - 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.
  • Magnitude (number) - The magnitude of the force.
  • InverseSquareLaw (bool) - When true, the force magnitude is multiplied by the inverse square of the distance.
  • Attachment0 - The base attachment. This Attachment is used to determine both the origin of the line that determines the direction of the force, along with where the force will be applied.
  • Attachment1 - The second attachment in the system. This Attachment is used to determine the end point of the line that determines the direction of the force.

##Torque
A TorqueActuator is used to apply a torque to a part or assembly. When active, this object will find the center of mass of the part or assembly connected to its Attachment0 and will apply a torque, spinning the part or parts.

###Direction of Torque
The direction of the spin is determined by the Torque and RelativeTo properties. The Torque defines the spin about the X, Y, and Z axes. However, these axes are oriented based on the RelativeTo property.

When RelativeTo is set to Attachment0, the torque will be oriented based on the local space of Attachment0. If Attachment0 moves or rotates, the torque will change to make sure it is still applying in the correct directions. Similarly, when RelativeTo is set to Attachment1, the torque will be applied based on Attachment1’s orientation, regardless of the position or direction of Attachment0. Last, RelativeTo can be set to World, which will use the world coordinate system to determine the axes for rotation.

###Properties

  • Enabled (bool) - Determines whether the Torque is active or not.
  • RelativeTo (enum - Attachment0, Attachment1, World) - The coordinate frame in which the Torque is expressed.
  • Torque (Vector3) - The strength and direction of the torque.
  • Attachment0 (Attachment) - The base attachment. The parent of this attachment is the part that will be affected by the torque.
  • Attachment1 (Attachment) - The attachment to use for the reference frame if RelativeTo is equal to Attachment1. Note that this only determines the direction of the attachment. The torque will still be applied to Attachment0. If RelativeTo is not equal to Attachment1 then this property is not used.

##AlignPosition
An AlignPosition is used to apply a force towards a location. Like other constraints, AlignPositions have two Attachments. In this case the attachments are constrained to be in the same position, although not necessarily in the same orientation. By default, this constraint only applies forces on Attachment0, although it can be configured to apply forces on both attachments.

###Reaction Force
AlignPositions by default only apply a force on Attachment0’s parent Part. The parent Part of Attachment1 remains unaffected. However, a force can also be applied to Attachment1 by enabling the ReactionForceEnabled. This will cause a force to be applied to both Attachment0 and Attachment1 in the direction of each other.
###Force Location
By default the force created by an AlignPosition is applied to the parent Part of Attachment0 at the Attachment’s location. The direction of the force is always towards Attachment1. This means that if the center of mass of the Part is not aligned with the direction of the force, a torque will be applied to the part as well as a force.

AlignPositions’ behaviors can be changed with the ApplyAtCenterOfMass property. When enabled, the AlignPosition will check if other Parts are rigidly connected to the parent Part of Attachment0. If there are, then the force will be applied at the center of mass of those connected parts. If not, then the force will be applied at the center of mass of the parent part itself.
###Force Magnitude
The force used to constrain an AlignPosition can either be configured or set to the maximum that constraints allow. Whether the force is configurable is determined by the RigidityEnabled property.

When RigidityEnabled is true, then the physics solver will use as much force as possible to move the two attachment points together. This is the same scale of force used to connect other constraints, such as hinges when their attachments are separated.

When RigidityEnabled is false, then the force will be determined by the MaxForce, MaxVelocity, and Responsiveness. MaxForce and MaxVelocity are caps to the force and velocities respectively. The actual scale of the force is determined by the Responsiveness. The mechanism for responsiveness is a little complicated, but put simply the higher the responsiveness, the quicker the constraint will try to reach its goal.
###Properties

  • Enabled (bool) - Determines whether the AlignPosition is active or not.
  • ApplyAtCenterOfMass (bool) - When true, applies force at center of mass of Attachment0’s parent Part. When false, applied at Attachment0.
  • ReactionForceEnabled (bool) - When true the constraint will apply force on both Attachments to achieve the goal.
  • RigidityEnabled (bool) - When true the solver will react as quickly as possible to move the attachments together. When false, force dependant on MaxForce, MaxVelocity, and Responsiveness.
  • MaxForce (float) - Maximum force the constraint can apply to achieve its goal. Only used if RigidityEnabled is false.
  • MaxVelocity (float) - Maximum speed the Attachment can move when converging. Only used if RigidityEnabled is false.
  • Responsiveness (float) - Used to control how quickly the constraint will reach its goal. Higher values will cause the attachments to move together quicker. Value can be between 5 and 200.
  • Attachment0 (Attachment) - The first attachment of the constraint.
  • Attachment1 (Attachment) - The second attachment of the constraint.

##AlignOrientation
An AlignOrientation is a constraint that applies a torque to make its attachments align. Like other constraints, this has two Attachments. In this case the two attachments are constrained to be oriented in the same direction but not necessarily the same position. By default, this constraint only applies torque on Attachment0’s parent, although it can be configured to apply torque on both attachments.

Note that any torque created by AlignOrientation will be applied about the center of mass of the parent of the attachments (or the center of mass of rigidly connected parts to the parents).

###PrimaryAxis
The behavior of an AlignOrientation is determined by its PrimaryAxisOnly property. By default this value is false and an AlignOrientation will work so that the orientation of its Attachment0 exactly matches the orientation of its Attachment1. It will apply torque about all 3 axes to achieve this goal.

If PrimaryAxisOnly is set to true, then the AlignOrientation will only apply torque if the primary axis of its Attachment0 becomes unaligned with Attachment1. This means that any rotation about the Attachment0’s primary axis will not create a torque.
###TorqueMagnitude
The torque used to constrain an AlignOrientation can either be configured or set to the maximum that constraints allow. Whether the torque is configurable is determined by the RigidityEnabled property.

When RigidityEnabled is true, then the physics solver will use as much torque as possible to move the two attachment points together. This is the same scale of force used to align other constraints, such as prismatics when their attachments are misaligned.

When RigidityEnabled is false, then the force will be determined by the MaxTorque, MaxAngularVelocity, and Responsiveness. MaxForce and MaxVelocity are caps to the torque and angular velocity respectively. The actual scale of the torque is determined by the Responsiveness. The mechanism for responsiveness is a little complicated, but put simply the higher the responsiveness, the quicker the constraint will try to reach its goal.
###Reaction Force
AlignOrientations by default only apply a torque on Attachment0’s parent Part. The parent Part of Attachment1 remains unaffected. However, a torque can also be applied to Attachment1 by enabling the ReactionForceEnabled. This will cause a torque to be applied to both Attachment0 and Attachment1 in equal and opposite directions.
###Properties

  • Enabled (bool) - Determines whether the AlignOrientation is active or not.
  • ReactionTorqueEnabled (bool) - When true the constraint will apply torque on both Attachments to achieve the goal.
  • RigidityEnabled (bool) - When true the solver will react as quickly as possible to align the attachments. When false, torque dependant on MaxTorque, MaxAngularVelocity, and Responsiveness.
  • MaxAngularVelocity (float) - The maximum angular velocity the constraint can use to reach its goal.
  • MaxTorque (float) - The maximum torque the constraint can use to reach its goal.
  • Responsiveness (float) - Used to control how quickly the constraint will reach its goal. Higher values will cause the attachment to align quicker. Value can be between 5 and 200.
  • Attachment0 (Attachment) - The first attachment of the constraint.
  • Attachment1 (Attachment) - The second attachment of the constraint.
84 Likes

These look awesome. I’m going to test them right now.

2 Likes

Yes! I’ve just begun using body movers in my recent game and I’m so excited to try them out since Body Force is an ugly way to do what I want.

What would you recommend for jet turbines?

4 Likes

This is awesome

1 Like

The only thing I don’t like is how it has to work with attachments. (Specifically, AlignPosition. It would be nice to specify a point and not just an attachment.)

Other than that, great update!

7 Likes

I love this! Been playing around with it for an hour now, the only thing I’d change is this:

Why is it a fixed 1 stud? I would love for this to be configurable so that you could have a sphere and do things like set the minimum distance to the radius of the sphere. You could then have the LineForce pull to the surface of the sphere instead of the center, making the force much more predictable. The use case is very small, but it should be relatively easy to implement? :slight_smile:

3 Likes

These look awesome! I can’t wait to play with them.

But just as an FYI, a lot of the text under Line Force mentions Vector Forces instead. copy ‘n’ paste bugs :slight_smile:

2 Likes

Been paying attention to this for awhile now.
Glad to see they’re finally coming out.

2 Likes

Is there any way to split up physics ownership of an assembly? Thinking of making some 2-player vehicles with these like a ship with a gimbal-locked turret manned by a second player, or a mobile platform with a crane attached to the top, where the crane is controlled by a second player. From what I understand, the easiest way is to have a dummy part in the portion controlled by player 2 which constantly sets it CFrame so that it follows player 1’s vehicle, but isn’t actually connected, and I’m wondering if there’s a more elegant way to do that.

3 Likes

Awww yisss. I’ve always used BodyGyro for needs along these lines, but setting a desired rotation is obviously not the same as applying a torque.

And BodyGyros choked up a bit when you completely flipped a part’s desired orientation.

3 Likes

This is just the convention. This means that the force applied is Magnitude/d^2 where d is the distance. By changing the magnitude you’ll get any desired behavior

2 Likes

I understand I can get the behavior I want by changing the magnitude, but API like this exists elsewhere in Roblox, for example sounds have minimum and maximum values for their rolloff. Not to mention constantly changing magnitude in a script would yield performance issues if I wanted to use this on a large scale.

2 Likes

An attachment is a point and orientation (and you can ignore the later for AlignPosition). If you didn’t know: attachments can be placed anywhere in space (you can parent them to the baseplate for example)

1 Like

I would recommend a VectorForce. Put an attachment on your turbine where you want the force to be applied and make sure the attachment is aligned with the direction you want the force to push. Then just make sure that the VectorForce you use is relative to Attachment0 (the one you put on the turbine).

3 Likes

I’m not sure that I understand. Why do you want to constantly change the magnitude? Gravity for example is given by:
F = GmM / d^2

so you set your magnitude to GmM only once

1 Like

Currently there is no way to split the ownership of a mechanism unfortunately. I don’t think we’ve sufficiently solved the distributed physics issues to easily allow such constructions.

2 Likes

Let me try to clarify. So this is what happens right now as in OP:

ActualMagnitude = Magnitude / (Separation ^ 2)

What I want is a minimum distance from where the inverse square law will be applied, lets call this MinDistance. Behavior would be this, when Separation > MinDistance:

ActualMagnitude = Magnitude / ((Separation-MinDistance) ^ 2)

When Separation < MinDistance, the constraint would behave as if InverseSquareLaw was false

1 Like

Understood. May I ask what is the design that requires this behavior? This doesn’t seem to be a common physical situation such as gravitational or electric field

1 Like

This is pretty niche and not very realistic, but I tried to simulate the current linear gravity (workspace.Gravity) while also keeping the exponential behavior of LineForce with InverseSquareLaw set to true when the player jumped high enough off of a sphere planet. I want this feature mostly because I found it very hard to replicate the default player movement and behavior when dealing with planetary gravity.

3 Likes

The fact that I have to attach it to something makes it a bit hacky, imo. But that’s just mo.

But then again, if we want to do stuff on roblox that isn’t directly supported, we always hack 'round it. :stuck_out_tongue:

1 Like