Use Motor6D C0 for BodyGyro CFrame component?

Hello!

I am making a system in which the player moves around using a body velocity. For aesthetics, I decided to then make the character tilt towards the direction of movement using the RootJoint of the HumanoidRootPart. After facing some issues with the character spinning out when colliding with something, I decided it would be a good idea to incorporate a BodyGyro to maintain the rotation.

(I know bodyGyro and bodyVelocity are deprecated.)

The issue is that the RootJoint.C0 doesn’t appear the same way for the BodyGyro:

local moveDirection = root.CFrame:VectorToObjectSpace(humanoid.MoveDirection)
tilt = tilt:Lerp(CFrame.Angles(math.rad(-moveDirection.Z) * 25, math.rad(-moveDirection.X) * 25, 0), 0.2 ^ (1 / (dt * 60)))
			
local moveVector = Vector3.new((humanoid.MoveDirection * 25).X, 0, (humanoid.MoveDirection * 25).Z)
			
tweenService:Create(movementForce, info, {Velocity = moveVector}):Play()
tweenService:Create(rootJoint, info, {C0 = rootC0 * tilt}):Play()
			
tiltForce.CFrame = rootC0
			
if humanoid.MoveDirection == Vector3.new(0, 0, 0) then
	tweenService:Create(rootJoint, info, {C0 = resetCframe}):Play()
	tiltForce.CFrame = resetCframe
end
NO BODYGYRO ACTIVE.

image

BODYGYRO ACTIVE.

image

I want it to be straight up when idle, and only slightly tilt towards the movement direction when moving. But with the BodyGyro enabled (gyro is used to enforce, so RootC0 is also in use with it), it seems to be oddly tilted backward. How can I fix this so that the BodyGyro can simply mimic the RootC0 rotation without messing it up?

Thank you for reading!

So you want something similar to a humanoid auto rotate feature which rotates the char when you press wasd?

Why not just sync the humanoid move direction with the body gyro then using CFrame.lookAt(pos, pos+direction)?

The force should be applied to the humanoid root part which is not effected by animations or root joint C0 changes.

1 Like

When the player moves, it slightly tilts them. That is working. I am just showing that the Gyro screws it up from the beginning. The RootC0 stuff works, the Gyro just can’t mimic it correctly for some reason.

Well then I believe the issue is that C0 is relative to the Part0 and body gyro expects a CFrame relative to the world.

Basically you cannot just shove C0 into body gyro.

To convert C0 to world space you will need to some weld CFrame inversing math like in my CFrame tutorial

However before that, does the root part move at all?

This is because the Part0 and part1 usually the rootPart and torso will affect the C0 calculation.

Perhaps just try setting body gyro CFrame to, and make sure it’s effecting the root part.

CFrame.lookAt(Vector3.zero, humanoid.MoveDirection)

This effect is similar to humanoid autorotate which is what I believe you want without overcomplicating the question with C0 stuff.

The animation tilt and the physics rotation should be completely separate just like how the default humanoid functions.