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.
BODYGYRO ACTIVE.
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!