Today we are releasing some new physics properties and functions for BaseParts! They do require some explanation, so read on!
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.
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 call
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
RootPriorityproperty. A more in-depth breakdown can be found here: https://developer.roblox.com/en-us/articles/understanding-root-parts
- 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
AssemblyLinearVelocityproperty 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.
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
BasePart.RotVelocity will be deprecated soon. There are 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
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, we will add
BasePart:GetVelocityAtPosition(Vector3 position) which will return the specific velocity for any point on your assembly (more flexible than BasePart.Velocity).
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!