I think the title explains the most. I’m at the start of making a new gun system for my game.
I thought, I’m gonna start with the camera! I got everything set-up, except for the rotation…
What it is:
What it should be:
How do I make the character turn to the cameras location (image 2)?
I believe this could be of some use
this script will turn the player to face camera look at just like you desired
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
-- Services
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local CCamera = game.Workspace.CurrentCamera
local OldCFrame = nil --// Variable to prevent unnecessary setting
-- Variable
RunService.RenderStepped:Connect(function()
--local CamCFrame = CCamera.CFrame.LookVector
local RootPos, CamPos = HRP.Position, CCamera.CFrame.LookVector * 100
local NewCFrame = CFrame.new(RootPos, Vector3.new(CamPos.X, RootPos.Y,CamPos.Z)) --//CFrame Equation
if OldCFrame ~= NewCFrame then
HRP.CFrame = NewCFrame
OldCFrame = HRP.CFrame
end
end)
The unecessary additons i made created some bugs my bad
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
-- Services
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local CCamera = game.Workspace.CurrentCamera
-- Variable
RunService.RenderStepped:Connect(function()
--local CamCFrame = CCamera.CFrame.LookVector
local RootPos, CamPos = HRP.Position, CCamera.CFrame.LookVector * 25
local NewCFrame = CFrame.new(RootPos, Vector3.new(CamPos.X, RootPos.Y,CamPos.Z)) --//CFrame Equation
HRP.CFrame = NewCFrame
end)```