How to make skinned character look toward mouse (Y axis)

I want my skinned mesh character’s spine bone to rotate in proportion to how much the player is looking up or down. To do this with normal characters it usually involves CFrame–so how would you go about doing it with bones and their orientation? I also do not think doing this on the client would replicate to the server, so any ideas on that would also be great.

I am not asking for an entire script since that would be ridiculous, but some ideas would be super helpful!

2 Likes

Replying to bump. Any help would be appreciated.

Bones should also use the CFrame of the attachments like in the post below, so you should be able to apply the same thing similar to Motor6D CFrame transformations.

1 Like

Will try that out, I didn’t think that would work. Guess I probably should have tested that out beforehand. Many thanks.

I am a little lost on what equation I should use to determine the CFrame of the bone; I don’t use CFrame very often. Do you have any pointers?

I would try using code from Motor6D and applying it to a bone.

For a Motor6D the CFrame offsets are C0 and C1 which are relative to the Part0 and Part1 respectively.

For a bone the CFrame offsets are just the attachment0.CFrame and attachment1.CFrame relative to the part it is attached attachment0.Parent and attachment1.Parent respectively.

1 Like

I’m still pretty much dumbfounded, I get the general idea but the process in my brain is hard; I’ll attempt to work my way through it. Thanks again!

Was able to find a simpler solution. Here’s the code in case anyone comes across a similar problem.

local runservice = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local cam = workspace.CurrentCamera
local bone = player.Character.HumanoidRootPart.Bip001['Bip001 Pelvis']['Bip001 Spine']['Bip001 Spine1']

runservice.Stepped:connect(function()

	local camPos = Vector3.new(0,0,180 - (cam.CFrame:ToOrientation() * 30))
	bone.Orientation = camPos

end)
5 Likes