How can I replicate this head turning?

How can I get the same head turning as in this game?


sorry for the crappy quality, the first recording was 93 mb and was 15 seconds long, obs or my pc was being rebarded for no reason, giving me unreasonably huge video sizes

1 Like

This has to do with Trigonometry, I found this video which should hopefully help your problem I’ve never worked with something like this before so hopefully this video helps

:slight_smile:

1 Like

Any idea why this happens?

1 Like

Do you have a walking animation for that ninja skin?

1 Like

R6 rigs have a weird problem where the axis with the neck joint is swapped, or something along the lines of that. Can you show your current code?

1 Like
local camera = workspace.CurrentCamera

local character = game.Players.LocalPlayer.Character
local root = character:WaitForChild("HumanoidRootPart")
local neck = character:FindFirstChild("Neck", true)
local yOffset = neck.C0.Y

local CFNew, CFAng, asin = CFrame.new, CFrame.Angles, math.asin

game:GetService("RunService") .RenderStepped:Connect(function()
	local cameraDirection = root.CFrame:toObjectSpace(camera.CFrame).lookVector
	
	if neck then
		neck.C0 = CFNew(0, yOffset, 0) * CFAng(0, -math.asin(cameraDirection.x), 0) * CFAng(math.asin(cameraDirection.y), 0, 0)
	end
end)
1 Like

Yea its a custom walking animation but i didn’t make it

1 Like

Here’s some working code, at least for a default R6 rig.
Keep in mind, this is client side ONLY.

local camera = workspace.CurrentCamera

local players = game:GetService("Players")

local character = players.LocalPlayer.Character or players.LocalPlayer.CharacterAdded:Wait()
local torso = character:WaitForChild("HumanoidRootPart")
local neck = character:FindFirstChild("Neck",true)
local neckC0 = neck.C0
local yOffset = neck.C0.Y

local CFAng = CFrame.Angles

game:GetService("RunService") .RenderStepped:Connect(function()
	local cameraDirection = torso.CFrame:ToObjectSpace(camera.CFrame).LookVector
	local head = character.Head or nil

	if neck and head then
		neck.C0 = neckC0 * CFAng(-cameraDirection.Y/1.7,0,-(((head.CFrame.Position - camera.CFrame.Position).Unit):Cross(torso.CFrame.LookVector)).Y)
	end
end)

You can tweak it how you like.

2 Likes

That is most likely the problem, unless it is really needed, I would remove the walking animation and see if it works

1 Like

No, I believe he has the axis wrong, he should try the script I provided.

I have a custom walking animation and it works flawlessly with my code.

2 Likes

Oh yeah, it works, thanks!

awewaeeae