(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)
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?
workspace:GetAttributeChangedSignal("reverse"):Connect(function()
if workspace:GetAttribute("reverse") then
script.Parent.Velocity *= -1
workspace:SetAttribute("reverse",false)
end
end)