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.

01-- 2d camera  script in ServerScriptService
02function setchar(p)
03    p.CameraMinZoomDistance = 5 --instead of 0.5 where they can "zoom in"/"angle" their character
04    local c = p.Character
05    while not p.Character or not p.Character.Parent do wait(.1) c = p.Character end
06    c:WaitForChild'HumanoidRootPart'
07    script.bpos:Clone().Parent = c.HumanoidRootPart
08end
09 
10for _,p in next, game.Players:GetPlayers() do
11    if p.Character and p.Character.Parent then
12        setchar(p)
13    end
14    p.CharacterAdded:connect(function()
15        setchar(p)
View all 23 lines...
01--2d script in starter gui
02p = game.Players.LocalPlayer
03rs = game:GetService('RunService')
04cam = workspace.CurrentCamera
05cam.CameraType = 'Scriptable'
06 
07rs.RenderStepped:connect(function()
08    if p.Character and p.Character:FindFirstChild('HumanoidRootPart') then
09        cam.CoordinateFrame = CFrame.new(Vector3.new(
10            30,
11            p.Character.HumanoidRootPart.Position.y+1.5,
12            p.Character.HumanoidRootPart.Position.Z
13            ),
14            p.Character.HumanoidRootPart.Position)
15    end
16end)
1--2d script in ReplicatedFirst
2wait(5)
3cam = game.Workspace.CurrentCamera
4 
5cam.CameraSubject = game.Workspace.Players
6cam.CameraType = "Attach"

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

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

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