Hello! I’m writing a map editor for a 2.5D game. By 2.5D, I mean 3D environments used in the typical fashion of 2D platformers like Super Mario Bros. To keep the immersion, I want the level editor’s Studio camera to be locked from rotating and moving by the Z axis. I tried this a while ago using the Command Bar, but I couldn’t change it, so I’m doubting I can do it, but hey! It doesn’t hurt to ask.
I just thought of a possible workaround, using a ViewportFrame (which might benefit the custom BGs I was planning on), but I don’t want to do it if I don’t have to; too much work lol
It is definitely possible even with the command bar, but it will take some effort. To do it right, you will need the script to detect mouse input as well with UserInputService or similar. What do you have so far?
I do not have anything so far, I just wanted to make sure it was possible before investing time into it. Thanks for the speedy reply!
If people will be using Roblox Studio to create maps, then this would most likely just frustrate them, and I wouldn’t recommend it
I’m thinking more of a toggle that my developers can use to view the level while they’re creating it. That, and what I have in mind for placement would be easier to use with a Z locked camera, in my opinion
So, I checked it out and I must’ve been doing it wrong. I was able to do it this time. Would a renderstep loop work here? I forgot what those are called
It would work, but I think that getting the mouse input through UserInputService would be better since it fires every time the mouse moves even a pixel.
I tried that last night, but it just didn’t work. I guess it’s how I do it? I’m accepting input through a GUI, and then using the main modulescript I use to move the camera, but the inputs don’t connect. Here’s my code, by the way.
(I’ve also tried UIS as you said, but it didn’t work either.)
local UIS = script.Parent.Parent
local PF = require(game.ReplicatedStorage.MapEditor_Stuff.source.PF)
script.Parent.Parent.InputBegan:Connect(function(inp)
if inp == Enum.KeyCode.W then
print("up")
PF.LockCamera(true, 1)
elseif inp == Enum.KeyCode.S then
PF.LockCamera(true, 2)
elseif inp == Enum.KeyCode.D then
PF.LockCamera(true, 3)
elseif inp == Enum.KeyCode.A then
PF.LockCamera(true, 4)
end
end)
I doubt you really need the LockCamera function, because my problem here is the inputs don’t work. Perhaps it’s because I’m running this through a LocalScript in a plugin?
I’ve just now realized my mistake…
I forgot to add .KeyCode to inp.
Now that that’s out of the way, how do I move the camera like a 2D one?
Alright, so I fixed the UIS stuff. But the studio camera seems to act differently than the in game camera: this’ll mess up the studio camera, while in-game is fine:
MEC is a part in Workspace
cameraHeight is 3
cameraZOffset is 20
game.Workspace.CurrentCamera.CFrame = CFrame.new(MEC.Position + Vector3.new(0, cameraHeight, cameraZOffset))
Alright, I’ve finally figured it out. I first fixed my obvious UserInputService issue, then mapped all my controls to WASD, and repeat movement until the key is released. I’m doing this all through a ViewportFrame now. Thank you for helping!
1 Like