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

How to change 2D camera to default camera when i touch a brick? [Updated and Urgent]

Asked by 8 years ago
Edited 8 years ago

I have a 2d camera setup made for my upcoming platformer (you cant move the camera and it follows you) I want to unlock it, and make it turn into normal camera when I touch a brick. For example, at the end of a level when I touch a brick to teleport to the lobby, I want the camera to unlock.

-- 2d camera  script in ServerScriptService
function setchar(p)
    p.CameraMinZoomDistance = 5 --instead of 0.5 where they can "zoom in"/"angle" their character
    local c = p.Character
    while not p.Character or not p.Character.Parent do wait(.1) c = p.Character end
    c:WaitForChild'HumanoidRootPart'
    script.bpos:Clone().Parent = c.HumanoidRootPart
end

for _,p in next, game.Players:GetPlayers() do
    if p.Character and p.Character.Parent then
        setchar(p)
    end
    p.CharacterAdded:connect(function()
        setchar(p)
    end)
end

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function()
        setchar(p)
    end)
end)
--2d script in starter gui
p = game.Players.LocalPlayer
rs = game:GetService('RunService')
cam = workspace.CurrentCamera
cam.CameraType = 'Scriptable'

rs.RenderStepped:connect(function()
    if p.Character and p.Character:FindFirstChild('HumanoidRootPart') then
        cam.CoordinateFrame = CFrame.new(Vector3.new(
            30,
            p.Character.HumanoidRootPart.Position.y+1.5,
            p.Character.HumanoidRootPart.Position.Z
            ),
            p.Character.HumanoidRootPart.Position)
    end
end)
--2d script in ReplicatedFirst
wait(5)
cam = game.Workspace.CurrentCamera

cam.CameraSubject = game.Workspace.Players
cam.CameraType = "Attach"

This is a script I made to try and fix the issue I am getting, but it doesn't work at all

script.Parent.Touched:connect(function()
    game.ServerScriptService.SideCamServer.Disabled = true
    game.StarterGui.SideCamClient.Disabled = true
    game.ReplicatedFirst.CameraScript.Disabled = true
end)

I hope someone replies soon as I cannot continue my development with this issue

1
Did you make this? User#11440 120 — 8y
0
No, got it as a free model Script0rr 65 — 8y
0
I don't know about others here but your use of the term "unlock" doesn't make since to me. It's not clear what you want to do. Could you please explain, in further detail, what you are trying to do? AZDev 590 — 8y
0
I think you want it to switch between the standard camera and the side view camera? In which case I think camera type would help you? I'm not sure... I don't do a lot with the camera, might wait until Perci1 or wfvj014 can maybe answer this? AZDev 590 — 8y
View all comments (3 more)
0
Ok, basically when I touch a brick I teleport to a lobby, which is where I want to move around freely with the camera unlocked, so I can move it around, and it follows me. Like the standard default camera Script0rr 65 — 8y
0
I believe resetting the camera to "Fixed" would place it back to the 'default' fashion. rexbit 707 — 8y
0
The default camera type is either 'custom' or 'classic', can't remember which. 'Scriptable' is likely to be more effective for your 2D space. saenae 318 — 8y

Answer this question