I am not good at camera manipulation can someone please help me figure this out. I want the player’s cam to face the same direction as another instance’s direction for example up,down,left,right
I can help with this! But, do you have any existing code for me to help you with?
I just got off my computer but basically I want it so the player’s camera faces down if the comers subject is facing down
Like this?
local camera = workspace.CurrentCamera -- or however you get the player's camera
local RunService = game:GetService("RunService")
local partToRotateCameraTo = workspace.Part -- refrence part here
RunService.RenderStepped:Connect(function()
camera.CFrame = CFrame.new(camera.CFrame.Position) * partToRotateCameraTo.CFrame.Rotation
end)
local basepart = --// Basepart
local camera = workspace.CurrentCamera
local rotation = basepart.CFrame.Rotation
local camera_pos = camera.CFrame.Position
camera.CFrame = CFrame.new(camera_pos) * rotation
That doesn’t work, it just rotates the camera instead of aligning it with the part.
I forgot to loop it, oops.
local basepart = --// Basepart
local camera = workspace.CurrentCamera
local rs = game:GetService("RunService")
rs.RenderStepped:Connect(function()
local rotation = basepart.CFrame.Rotation
local camera_pos = camera.CFrame.Position
camera.CFrame = CFrame.new(camera_pos) * rotation
end)
No I thought of CFrame * Rotation
wait nvm i didn’t look at the while thing sorry lol
you could also add a lerp to make it smoother
local camera = workspace.CurrentCamera -- or however you get the player's camera
local RunService = game:GetService("RunService")
local partToRotateCameraTo = workspace.Part -- refrence part here
RunService.RenderStepped:Connect(function(dt)
camera.CFrame = camera.CFrame:Lerp((CFrame.new(camera.CFrame.Position) * partToRotateCameraTo.CFrame.Rotation), 0.25)
end)
A lerp is a camera animation?
extra text…
it just smoothly moves in between positions with a set interval. so if you set the interval to 0.5 it will get 50% closer to the target position every update.