Hey there,
I've dug up an old isometric view script I found on Reddit (Script A, found below), and I'd like to add a few lines that make it so that upon pressing 'E' (or any other button, for that matter) the camera angle changes as it does in Script B (found below). The reason I'm not just using Script B is because upon using it, things like particle emitters and lights dissappear for some reason.
In the end, I'd greatly appreciate any help with either making the angle button OR finding a solution to the graphical bug in Script B.
If a solution is found to this, I'll put it open to the public for everyone to use, and any proper help will be credited.
SCRIPT A (local script in StarterPlayerScripts)
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local dir = CFrame.Angles(math.pi/4, math.pi/4, 0)
local angle = 0
repeat wait() until plr.Character
local char = plr.Character
local cam = game.Workspace.CurrentCamera
local zoom = 100
local FOVsmall = true
cam.FieldOfView = 10
cam.CameraType = Enum.CameraType.Scriptable
mouse.WheelForward:Connect(function()
if zoom > 80 then
zoom = zoom - 2
else
zoom = 80
end
end)
mouse.WheelBackward:connect(function()
if zoom < 250 then
zoom = zoom + 2
else
zoom = 250
end
end)
while true do
game["Run Service"].RenderStepped:wait()
if char then
if char:FindFirstChild("Head") then
cam.CoordinateFrame = CFrame.new(Vector3.new(char.Head.Position.X+zoom,char.Head.Position.Y+zoom,char.Head.Position.Z+zoom),char.Head.Position)
end
end
end
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E then
angle = angle+1
dir = CFrame.Angles(-math.pi/4, math.pi/4*angle, 0)
elseif inputObject.KeyCode == Enum.KeyCode.Q then
angle = angle-1
dir = CFrame.Angles(-math.pi/4, math.pi/4*angle, 0)
end
end
SCRIPT B (local script in StarterPlayerScripts)
local dir = CFrame.Angles(math.pi/4, math.pi/4, 0)
local shifte = CFrame.Angles(0, math.pi/2, 0)
local shiftq = CFrame.Angles(0, -math.pi/2, 0)
local localplayer = script.Parent.Parent
local angle = 0
game.Workspace.CurrentCamera.FieldOfView = 1.5
local FOVsmall = true
local function fieldOfViewAdjust()
if FOVsmall == true then
game.Workspace.CurrentCamera.FieldOfView = 1.5
FOVsmall = false
elseif FOVsmall == false then
game.Workspace.CurrentCamera.FieldOfView = 4
FOVsmall = true
end
end
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E then
angle = angle+1
dir = CFrame.Angles(-math.pi/4, math.pi/4*angle, 0)
elseif inputObject.KeyCode == Enum.KeyCode.Q then
angle = angle-1
dir = CFrame.Angles(-math.pi/4, math.pi/4*angle, 0)
elseif inputObject.KeyCode == Enum.KeyCode.T then
fieldOfViewAdjust()
end
end
game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
function center()
return (localplayer.Character and localplayer.Character:FindFirstChild'Head' and localplayer.Character.Head.Position) or Vector3.new()
end
workspace.CurrentCamera.CameraType = 'Scriptable'
while wait(1/60) do
workspace.CurrentCamera.CameraType = 'Scriptable'
workspace.CurrentCamera:Interpolate(
CFrame.new(center() + (CFrame.Angles(0, math.pi/4+math.pi/2*angle, 0).lookVector + Vector3.new(0, 1, 0))*1000, center()),
CFrame.new(center(), center()),
0.01
)
end
Thanks in advance!
