Today we are releasing some new physics properties and functions for BaseParts! They do require some explanation, so read on!
Assemblies
First, we’ve added five new properties that further introduce a concept that may be new to some of you: the assembly.
In Roblox, an assembly is a set of unanchored parts connected by WeldConstraints, Motor6Ds, or other rigid joints. Internally, these parts form a single rigid body with a velocity, position, and mass.
Read more about assemblies here!
These properties are now all exposed as properties of the BasePart:
-
float AssemblyMass
[read only] - The total mass of the part’s assembly. -
Vector3 AssemblyCenterOfMass
[read only] - The world space position of the part’s assembly’s center of mass. -
Vector3 AssemblyLinearVelocity
- The linear velocity of the part’s assembly (at its center of mass). -
Vector3 AssemblyAngularVelocity
- The angular velocity of the part’s assembly. -
BasePart AssemblyRootPart
[read only] - A reference to the root part of the assembly (the same part that’s returned when you callPart:GetRootPart()
).
More things to know about assemblies:
- When working with a single part, that part is an assembly itself.
- Every assembly has a root part. The root part is defined by several factors including the
RootPriority
property. A more in-depth breakdown can be found here: Documentation - Roblox Creator Hub - An assembly only exists in the Workspace or another WorldModel instance. If you have a set of parts welded/connected and stored outside of Workspace/WorldModel, all of those connections are disabled and each part becomes its own assembly.
- When one of the parts in an assembly is anchored, that part becomes the root part and all the other parts become implicitly anchored with it. You could think that the whole assembly is anchored, and you can still set the
AssemblyLinearVelocity
property for conveyor belt behavior. - Once more than one of the parts in an assembly is anchored, the assembly will split, with each anchored part being the root part of its own assembly. If you anchor all the parts, they all become their own assembly.
Impulses
A much requested feature has been for a method to apply an impulse to parts. An impulse can be interpreted as an instantaneous force or impact applied to a part for a single physics step. This is ideal for launching physics-based projectiles!
-
void ApplyImpulse(Vector3 impulse)
- apply an impulse to the assembly at the assembly’s center of mass -
void ApplyImpulseAtPosition(Vector3 impulse, Vector3 position)
- apply an impulse to the assembly at specified position. -
void ApplyAngularImpulse(Vector3 angularImpulse)
- apply an angular impulse to the assembly
Looking Forward (Activated as of Feb 3!)
BasePart.Velocity
and BasePart.RotVelocity
are now deprecated (hidden from Properties window). There were multiple issues in their operation when dealing with a part and its assembly. For example, setting velocity on a part that isn’t a root part just doesn’t work, but it always reads the velocity of the specific part. The AssemblyLinearVelocity
and AssemblyAngularVelocity
properties, along with the new impulse functions, should provide all of the options necessary for setting specific velocities.
As for reading linear velocities of specific parts or positions, BasePart:GetVelocityAtPosition(Vector3 position)
has been added which will return the specific velocity for any point on your assembly (more flexible than BasePart.Velocity).
Conclusion
Thanks for reading this big post! We are working on a more in-depth and definitive article about Assemblies for the developer hub. If you have questions, please post them here!
FAQ: