So let’s say I want to make my torso swivel but not my whole body, or my head to swivel, how would I do that?
I believe you would use animations.
But let’s say I want the character’s torso to always be facing the camera, how would I do that with animations?
You would want to programmatically implement that by modifying the motor6d joints of the character. The easiest way would be to edit the transform of the motor6d since that preserves the default joint offsets. However this overrides any animations so if you want to preserve that on top of your joint modifications you should edit either the C0 or C1 properties of the joint, taking into account the original offset of the joint. This would be implemented continuously with RunService, using the Stepped event for editing the transform property or Heartbeat to edit the C0 and C1.
How would I do that? I don’t mind if it overrides animations, I’d want that anyway.
Edit: Nevermind, I think I know how to do it by editing c0. Thanks.
Yea, also after experimenting a bit I recommend you do some interpolation because using stepped and heartbeat I found it to be rather jittery. Heres what I did:
-- in starter character scripts
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local character = script.Parent
local lowerTorso = character:WaitForChild("LowerTorso")
local waist: Motor6D = character:WaitForChild("UpperTorso"):WaitForChild("Waist")
local lastTransform = waist.Transform
runService.Stepped:Connect(function(td)
local objSpaceCF = lowerTorso.CFrame:ToObjectSpace(camera.CFrame)
objSpaceCF = objSpaceCF - objSpaceCF.Position
waist.Transform = lastTransform:Lerp(objSpaceCF, 0.25)
lastTransform = waist.Transform
end)
Nice, that’s just the effect I wanted for my game