BodyVelocity/LinearVelocity acting weirdly on diagonals

(The red line is visualizing the part’s AssemblyLinearVelocity)

For some reason the AssemblyLinearVelocity of the part swings around, even though I’m just multiplying BodyVelocity.Velocity by -1.

Example:

The unusual behavior only happens on diagonals. When BodyVelocity.Velocity is perfectly aligned to an axis (eg. 20,0,0) it will behave as expected:

Any help with this is appreciated since I’m using BodyVelocity for a custom movement system and the effect is really noticeable.

It occurs with both BodyVelocity and LinearVelocity, and I need to solve this problem without increasing MaxForce or the mass of the part, as that would mess up other aspects of the movement.

Place used in the example videos:
velocity bug.rbxl (40.7 KB)
(ran as server only, there’s an attribute on the workspace which when clicked will reverse the BodyVelocity's velocity)

What’s the code you’re using to set the velocity?

sorry I’m late, roblox devforum decided to delay the notification for some reason

this script is in the BodyVelocity

workspace:GetAttributeChangedSignal("reverse"):Connect(function()
	if workspace:GetAttribute("reverse") then
		script.Parent.Velocity *= Vector3.new(-1,1,-1)
		workspace:SetAttribute("reverse",false)
	end
end)

This flips velocity on the X and Z axes which I assume is what you want. The problem is that the flip is in world space. I assume you want it to always flip around a specific axis of the part, regardless of the part’s current rotation?

I want the vector to just shrink to 0 and then start expanding like it does in the second video, but for some reason on diagonals it doesn’t do that.

Its because the direction you’re flipping it changes when the part rotates. Do you want it to always flip through the part the same way?

yeah, I want the velocity to reverse like it does in the second video but when facing any direction

Have you tried this?

workspace:GetAttributeChangedSignal("reverse"):Connect(function()
	if workspace:GetAttribute("reverse") then
		script.Parent.Velocity *= -1
		workspace:SetAttribute("reverse",false)
	end
end)

yeah, but its basically the same since I’m leaving the Y axis at 0

(come to think of it, I probably should have mentioned that :skull:)