-
What do you want to achieve?
I want rotating heads like every gun engines such as war bound, carbon engine and more.
but every I equipped when the character facing to other direction, the head facing front instead of character direction. -
What is the issue?
What I want : `
robloxapp-20230128-1257243.wmv (981.9 KB)
What the server did :
robloxapp-20230128-1259595.wmv (2.4 MB)
-
What solutions have you tried so far?
It must be CFrames but I couldn’t find the error
-- This is how any fps engine (such as TB,WB,CE,etc..) head move.
local model = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local head = model:FindFirstChild("Head")
local originalOri = 90 -- Don't change anything! Keep this number
local originalEA = 3.15 -- Don't change anything! Keep this number
local orginalC0 = CFrame.new(0, 1.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
local neck = model:FindFirstChild("Torso").Head
head.Orientation = Vector3.new(-originalOri,0,0)
game:GetService("RunService").RenderStepped:Connect(function()
local Direction = workspace.CurrentCamera.CFrame.p
local b = head.Position.Y - Direction.Y
local dist = (head.Position - Direction).magnitude
local answer = math.asin(b/dist)
neck.C0 = orginalC0 * CFrame.fromEulerAnglesXYZ(-answer,originalEA,0)
wait(0.1)
end)