I recently made a custom controller for my game and i am trying to make the character face the camera direction while still being able to rotate freely on other axis
The problem is that the character don’t rotate correctly on ramp
it work like this but as soon as i rotate the camera it start bugging
Here’s my code so far:
local x, y, z = game:GetService("Workspace").CurrentCamera.CFrame:ToOrientation();
local xP, yP, zP = Character.PrimaryPart.CFrame:ToOrientation()
local speed = 10
if IsSideway == false or IsJumping == true then
if IsJumping == true then
speed = 8
IsJumping = false
end
Character.PrimaryPart.CFrame = Character.PrimaryPart.CFrame:Lerp(CFrame.new(Character.PrimaryPart.Position) * CFrame.Angles(xP, y, zP), deltaTime * 5 * speed);
end
I know it has something to do with the xP, y and zP but i can’t find a solution