Are there any fixes to this weird velocity bug?

So, I have a game which contains lots of animations which heavily move your torso during them, and that part is fine. However, Moving the humanoidRootPart using CFrame will result in unnatural changes to the character’s physics, which really ruin the experience. I’ve yet to capture a full on video of the event happening in my game (my duct tape fix works with people on average ping, so I dont have footage of it right now.)

Update 1: My friend clipped it happening for me, and I’ve attached that now.

Have you tried BodyVelocity?
BodyVelocity | Documentation - Roblox Creator Hub

My game uses BodyVelocity for some knockback states, and this current post is about weird offset issues caused by weird animation cases

You mentioned that you are using CFrame to move the HumanoidRootPart, so i assumed.

And the issue you are having is probably because of that, so i suggest using BodyMovers like BodyVelocity

The issue mainly stems from stopping the animation and moving them to a specific location, which changing the cframe does fine. I wish to find a fix to the velocity issue, even if it happens for a little a longterm fix would be lovely. Any way to detect it would be good at this rate

Can you give me more context about what are you trying to do?

I have no real idea on how to detect when the weird velocity bug is occuring (because it could range from very minimal things like being unable to move left while jumping). My “duct tape fix” is just anchoring and unanchoring, which does “fix” the issue, but high ping players are still out of the loop.

1 Like

Are you using BodyVelocity to move the character?

If so, you might want to divide the velocity for which the character moves when they’re in the air.

if hum.FloorMaterial == Enum.Material.Air then
       velocity = hrp.CFrame.lookVector * -(force/1.5)
end

The person in the video has no BodyVelocity. No velocity objects, no nothing. It just behaves like that after the bug happens.

It happens due to changing the CFrame directly; so yeah, try using BodyVelocity

Sorry for the very late response, but the bug also occurs when there are NO changes to CFrame during a distant animation. No anchoring, no nothing.

Update: I finally discovered how to detect said issue!

When your character is in a state where they shouldnt have offset (for my case, its being not anchored wtih rootpart)

Read their HumanoidRootPart’s AssemblyCenterOfMass, and when its offseted, the difference will be big.
I did a magnitude check between AssemblyCenterOfMass and the RootPart’s Position, which got me a number to use. For me, anything above 0.8 was weird offset issues, so I made it quickly fix said issue. Works like a charm now!

I’ve had people reach out, so here’s the code snippet.
(This method isnt optimal, if you find other ways of balancing out mass, please sub it out instead of this.)

LocalScript in StarterCharacterScripts:


local RunService = game:GetService("RunService")

local Character = script.Parent
local HumanoidRootPart : Part = Character:WaitForChild("HumanoidRootPart")

local FixCooldown = false
local FixTick = nil

RunService.RenderStepped:Connect(function()
	if (HumanoidRootPart.AssemblyCenterOfMass - HumanoidRootPart.Position).Magnitude >= 1 then
		
		if FixCooldown == true and (FixTick and tick() - FixTick >= 0.5) then
			FixCooldown = false
			FixTick = nil
		end
		
		if FixCooldown == false then
	
		     FixTick = tick()
		
			local anchored = HumanoidRootPart.Anchored
			if anchored == false then
				HumanoidRootPart.Anchored = not anchored
				task.wait()
				HumanoidRootPart.Anchored = anchored
			end
		end
	end
end)

Moving the CFrame of the HumanoidRootPart causes odd offset effects move the model via Model:MoveTo() or Model:SetPrimaryPartCFrame() instead

This works and fixes it though

I probably should have read the latest comment lol, have a great day

1 Like