I have found some topics regarding top-down camera view but they all seem to be unanswered and the youtube videos seem to have outdated code.
Could someone help me out with this?
I have found some topics regarding top-down camera view but they all seem to be unanswered and the youtube videos seem to have outdated code.
Could someone help me out with this?
If i understand you right you want to create something like this?
Yes that is what I am wanting.
I should’ve provided a video example in my original post but ah well.
Alright! its pretty simple.
Set “CameraType” property to Scriptable. This will lock the camera completley letting you freely code its behavior yourself.
Bind a function to “RenderStepepd” to update each frame. Inside this function position the Cameras CFrame onto the players HumanoidRootPart(Or whatever part you specified) position plus add the HumanoidRootPart’s UpVector and multiply it by the variable called “StudsY” and rotate it by -90.
This will position the Camera 20 studs above the HumanoidRootPart and point down.
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Primary = Char:WaitForChild("HumanoidRootPart")
local Cam = workspace.CurrentCamera
local StudsY = 20 -- Customize however you want.
local function Enable()
Cam.CameraType = Enum.CameraType.Scriptable
game["Run Service"].RenderStepped:Connect(function()
Cam.CFrame = CFrame.new(Primary.Position + Primary.CFrame.UpVector*StudsY) * CFrame.Angles(math.rad(-90),0,0)
end)
end
Enable()
But if you dont want the camera to also move up when the player jumps like you can see in the video use this code instead.
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Primary = Char:WaitForChild("HumanoidRootPart")
local Cam = workspace.CurrentCamera
local StudsY = 20
local function Enable()
Cam.CameraType = Enum.CameraType.Scriptable
game["Run Service"].RenderStepped:Connect(function()
Cam.CFrame = CFrame.new(Primary.Position.X,StudsY,Primary.Position.Z) * CFrame.Angles(math.rad(-90),0,0)
end)
end
Enable()
Thanks for the help. One more question though, does CFrame.Angles determine the orientation of the camera in radians?
Yeah sorry my bad its determined in radians
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.