Setting the Velocity of an unanchored welded part, causes all other parts welded to the same one to also have their Velocity set

When setting the Velocity of a unachored part that is welded to another anchored part, the other part will also have its Velocity affected.


In the video above, I created an example of the bug :

The Yellow Part : A anchored part (Named AnchoredPart)
The Green Part : A unanchored part (Named LeftConveyor) , welded to the Yellow Part
The Red Part : A unanchored part (Named RightConveyor) , welded to the Yellow Part

image

Below is the script used to set the velocity of the green and red part.

for i,v in script.Parent:GetDescendants() do -- Sets everything to 0 Velocity to help test bug easier
    if v.ClassName == "Part" then
        v.Velocity = Vector3.new(0,0,0)
    end
end
-- now lets give each conveyor their own velocity
script.Parent.AnchoredPart.LeftConveyor.Velocity = Vector3.new(-50,0,0) -- this should set only the LEFT conveyor
script.Parent.AnchoredPart.RightConveyor.Velocity = Vector3.new(50,0,0) -- this should set only the RIGHT conveyor
-- Actual Result : 
-- Every part welded to the AnchoredPart including AnchoredPart will have the Velocity from line 8 (RightConveyor)

This script is setting the velocity of the green part to Vector3.new(-50,0,0) and the red part to Vector3.new(50,0,0)

Both green part (LeftConveyor) and red part (RightConveyor) should have different Velocity’s, but both parts (including the yellow part which I did not set a velocity to), all have the same velocity which is the last Velocity set by the script which was for the red part.

Expected behavior

I expect that when I set the Velocity to one part, it does not affect the Velocity of any other part.

Work around : Anchor both the green part and the red part, and both parts will have their Velocity set normally as shown in the script.

1 Like

Hi, thanks for posting!

The behavior you’re observing is a bit subtle. In the Roblox physics engine, we handle velocities at the assembly level. An assembly is a collection of parts that are connected by welds or Motor6Ds. So, when you set the velocity of any part in an assembly, you’re also setting the velocity for all of the other parts in the assembly. That’s why all parts have the velocity of RightConveyer in the example you posted.

Why do things work this way? All parts in an assembly move as a single rigid body. A weld between any two parts ensures that the parts move as a single rigid body, i.e. that there is no relative motion between those parts. That is why we introduced BasePart.AssemblyLinearVelocity, which has the same effect as setting BasePart.Velocity, but is named to more clearly communicate its effect.

For the example you posted, you can simply anchor the conveyer parts and remove the welds between AnchoredPart and the conveyer parts.

3 Likes

Hi there, thank you for responding!

Now that I’ve read your response it does make more sense, I was just caught off guard when encountering this behavior for the first time as I’ve never seen Velocity being set to multiple parts at the same time.

The original reason I wanted to weld multiple conveyors together was so that I could make a cool obby / attack design by being able to simply move all of them together and giving myself more options on how I could animate them such as manipulating weld cframes.

Since this is an intended behavior, I’ll mark your response as the solution to close this topic and find a different way I could make my idea, thanks again for responding!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.