Make the Camera Draggable?

I got you man im working on it right as we speak

1 Like

Yeah Is basically hard, you want your camera move just like in avatar editor? where you can inspect your items?

He want his camera to be draggable, why are you mentioning viewport?

Making camera draggable is different thing than a viewport frame.

Have you ever played Township or one of those tycoon games on the App Store? The camera movement system like that is what I’m looking for but @dexanddeb says he understands what I’m talking about so I should be ok.

Ohh, understandable.
I can try making it, I am not so familiar with this kind of stuff, but I’ll try.

Do you need to hold left mouse button to move your camera?

Left or right and having it work on mobile would be great too.

Make a part in Workspace named “CamPlace” and then set orientation to “-90, 0, 0”
Uploading: image.png…
image
then insert a local script in starterplayer scripts doesn’t matter what you name it
image
and insert this into the local script:

local UserInputService = game:GetService("UserInputService") 
local RunService = game:GetService("RunService") 

local plr= game.Players.LocalPlayer
local char = game.Workspace:WaitForChild(plr.Name)

local Camera = game.Workspace.CurrentCamera 
Camera.CameraType = "Scriptable" 
Camera.CFrame = CFrame.new(0,0,0) 
Camera.CFrame = game.Workspace.CamPlace.CFrame

local W,A,S,D,NotMoving = false,false,false,false,true

local function KeepMoving()
	repeat 
		if 	W then 
			Camera.CFrame = Camera.CFrame + (Camera.CFrame.UpVector * 0.4)
		end
		if 	S then 
			Camera.CFrame = Camera.CFrame + (Camera.CFrame.UpVector * -0.4)
		end
		if 	A then 
			Camera.CFrame = Camera.CFrame + (Camera.CFrame.RightVector * -0.4)
		end
		if 	D then 
			Camera.CFrame = Camera.CFrame + (Camera.CFrame.RightVector * 0.4)
		end

		RunService.RenderStepped:Wait()
	until NotMoving
end


local function MoveBegan(actionName,inputState,input)

	if  input.UserInputType == Enum.UserInputType.Keyboard then

		if UserInputService:IsKeyDown(Enum.KeyCode.W) then
			W = true
			NotMoving= false
		end
		if UserInputService:IsKeyDown(Enum.KeyCode.A) then
			A = true
			NotMoving= false
		end
		if UserInputService:IsKeyDown(Enum.KeyCode.S) then
			S = true
			NotMoving= false
		end
		if UserInputService:IsKeyDown(Enum.KeyCode.D) then
			D = true
			NotMoving= false
		end
	end

	if W and not A and not S and not D then
		KeepMoving()
	elseif not W and not A and not S and  D then
		KeepMoving()
	elseif not W and not A and not S and  D then 
		KeepMoving()
	elseif not W and not A and not S and  D then 
		KeepMoving()
	end

end 




local  function MoveEnded(input, gpe)

	if input.KeyCode == Enum.KeyCode.W then
		W = false
	elseif input.KeyCode == Enum.KeyCode.S then
		S = false
	elseif input.KeyCode == Enum.KeyCode.D then
		D = false
	elseif input.KeyCode == Enum.KeyCode.A then
		A = false
	end
end

if not W and not S and not D and not A then	
	NotMoving = true
else
	NotMoving = false
end



game:GetService("ContextActionService"):BindAction("MoveCam" , MoveBegan, false,Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D)
UserInputService.InputEnded:Connect(MoveEnded)

wait(10)
	print("Script Is Functional")

You can edit this to move using the mouse

oh, if that’s the case, lock the camera, and you can use game.Workspace.currentcamera, something like this, lock the Y to a Y coord, then, you can use user input mouse to detect when mouse is held down, then do math behind the initial press, and the let go, to then move the X and Y coords.

:joy: I actually currently have a WASD camera move script and I’m trying to switch from that to using the mouse for a faster/smoother experience and compatibility. I did try to change it but it didn’t even get close to working thus why I created this topic.

Dont worry im still working on one that doesnt require a part and supports dragging with mouse

1 Like

Thank you so much you’re a live saver!

1 Like

Then why didn’t you specifiy that?

Hey so while looking around, I found this dev post which seems to have the solution you are looking for.

I have a video which shows how it should look:

I didn’t realise you were looking for a WASD script. Because at the time it wasn’t relevant.

Dang beat me too it, good work!

The post looks like what I want but in your video you just hold the mouse down and the camera moves by itself.

1 Like

You have to drag to make it move.

1 Like

yay in that case im still working on mine

1 Like