Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How should I go about changing angles for this isometric view script?

Asked by
souflee 50
4 years ago

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!

1 answer

Log in to vote
0
Answered by
souflee 50
4 years ago

Alright lads! I managed to find another script, and I tweaked it a bit to my liking - if anyone would like to edit it themselves; here is the code. It's in a local script in PlayerCharacterScripts.

Happy scripting!

repeat wait() until game.Players.LocalPlayer.Character

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local character = player.Character

local FovSmall = true

camera.CameraType = Enum.CameraType.Scriptable
character.Humanoid.WalkSpeed = 16
local rotate = 0
local debuging = false

function cameramove ()
    workspace.CurrentCamera.CFrame = CFrame.new(character.HumanoidRootPart.Position)*CFrame.Angles(0,math.rad(rotate),0)*CFrame.new(Vector3.new(50,100,50),Vector3.new(character.HumanoidRootPart.Position))
end
function rotatechange(input,event)
    if input.KeyCode == Enum.KeyCode.E then -- might need to update this aswell as Enum.Keycode.Q

        for i = rotate,rotate+90,10 do 
            rotate = i
            wait()
        end
        wait(1)
        debuging = false
    end
    if input.KeyCode == Enum.KeyCode.Q and debuging == false then
        debuging = true
        for i = rotate,rotate-90,-10 do 
            rotate = i
            wait()
        end
        wait(1)
        debuging = false
    end
if input.KeyCode == Enum.KeyCode.T then
if FovSmall == true then
game.Workspace.CurrentCamera.FieldOfView = 20
FovSmall = false
    elseif FovSmall == false then
    game.Workspace.CurrentCamera.FieldOfView = 35
    FovSmall = true
end
end
    end

game:GetService("RunService"):BindToRenderStep("Camera",1,cameramove) 
game:GetService("UserInputService").InputBegan:connect(rotatechange)
Ad

Answer this question