Making An orbitial/moveable camera like this,
I don’t have much experience with scripting cameras in studio but this should be fairly simple to do.
The first thing to do is to create a local script that changes the camera to Scriptable and then changes the CFrame of the camera while also making sure the Focus of the camera is the Humanoid.
The code should probably look something like this:
local Player = game.Players.LocalPlayer
local Humanoid = Player.Character:FindFirstChild("Humanoid")
local Camera = game.Workspace.CurrentCamera
local uis = game:GetService("UserInputService")
local xaxis = 0
local yaxis = 0 --change these numbers to your liking as I'm assuming the z axis is constant
Camera.CameraType = Enum.CameraType.Scriptable
Camera.Focus = Humanoid
Camera.CFrame = CFrame.new(x,50,y)
while task.wait() do --Now to move the camera depending on the key pressed
if uis:IsKeyDown(Enum.KeyCode.W) then
xaxis += 1
Camera.CFrame = CFrame.new(x,50,y)
end
if uis:IsKeyDown(Enum.KeyCode.S) then
xaxis -= 1
Camera.CFrame = CFrame.new(x,50,y)
end
if uis:IsKeyDown(Enum.KeyCode.A) then
yaxis -= 1
Camera.CFrame = CFrame.new(x,50,y)
end
if uis:IsKeyDown(Enum.KeyCode.D) then
yaxis += 1
Camera.CFrame = CFrame.new(x,50,y)
end
end
I’m not too sure if this code will work but I think it’s a decent starting point to fix, optimize and implement new things to.
ill test it and try to fix any errors
Also make sure to assign different keybinds or change the walkspeed of the player to 0 if you don’t want him to move
alright i will make sure of that
it works, but how would i make it face towards the ground like it was in the video?
nevermind i figured it out, i changed it up a bit
here’s the changed script:
repeat wait() until game.Players.LocalPlayer.Character ~= nil
local Player = game.Players.LocalPlayer
local Humanoid = Player.Character:FindFirstChild("Humanoid")
local Camera = game.Workspace.CurrentCamera
local uis = game:GetService("UserInputService")
local xaxis = 0
local yaxis = 0 --change these numbers to your liking as I'm assuming the z axis is constant
Camera.CameraType = Enum.CameraType.Scriptable
Camera.Focus = Player.Character.HumanoidRootPart.CFrame
Camera.CFrame = CFrame.new(Player.Character.HumanoidRootPart.Position + Player.Character.HumanoidRootPart.CFrame.UpVector*80) * CFrame.Angles(math.rad(-90),0,0)
Camera.CameraSubject = workspace.Baseplate
while task.wait() do --Now to move the camera depending on the key pressed
if uis:IsKeyDown(Enum.KeyCode.W) then
yaxis += 1
game.TweenService:Create(Camera, TweenInfo.new(.1, Enum.EasingStyle.Sine), {CFrame = CFrame.new(xaxis, 80, yaxis) * CFrame.Angles(math.rad(-90),0,0)}):Play()
end
if uis:IsKeyDown(Enum.KeyCode.S) then
yaxis -= 1
game.TweenService:Create(Camera, TweenInfo.new(.1, Enum.EasingStyle.Sine), {CFrame = CFrame.new(xaxis, 80, yaxis) * CFrame.Angles(math.rad(-90),0,0)}):Play()
end
if uis:IsKeyDown(Enum.KeyCode.A) then
xaxis -= 1
game.TweenService:Create(Camera, TweenInfo.new(.1, Enum.EasingStyle.Sine), {CFrame = CFrame.new(xaxis, 80, yaxis) * CFrame.Angles(math.rad(-90),0,0)}):Play()
end
if uis:IsKeyDown(Enum.KeyCode.D) then
xaxis += 1
game.TweenService:Create(Camera, TweenInfo.new(.1, Enum.EasingStyle.Sine), {CFrame = CFrame.new(xaxis, 80, yaxis) * CFrame.Angles(math.rad(-90),0,0)}):Play()
end
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.