Control camera/character with one specific gamepad - easiest way?

:wave: Hiya


I want to make the camera and character movement system only work with a specific gamepad (for example, from Enum.UserInputType.Gamepad1.
I would like inputs from other gamepads and other input types (mouse, keyboard etc.) to be ignored by the camera and movement system.


The issue

The issue is that I don’t know what would be the best way to do this. I would like to know if it can be done with the default scripts with very small adjustments (probably not), or if I would have to make whole camera and movement controllers, or if there are other easier ways.


What have I tried?

So far, I have tried using my brain (rare thing). For the camera, I could perhaps set it to Scriptable and work out something from there.
I don’t want to make a whole movement system (lazy :joy:), but if that’s the easiest way, I will. I have also searched for anything related to my issue online, and didn’t really find anything I want there.


Additional details

I am not looking for full scripts/systems, as I haven’t even gotten that far yet. All I’m looking for is to know what way would be the easiest to make this. I can then go ahead and start scripting. If you want to provide script examples, you can do that.

I would normally start scripting immediately, but I have never worked on something like this, so I don’t want to waste my time.


I can try to change the category if it’s not the correct one.
Thank you very much!

2 Likes

Found a solution.
I found out the easiest way was to handle movement in a script, using Humanoid:Move. When I found that out, I also got to work.

I found this topic after a long search which really helped, and put the IntControls function into my script, which handled the controls.

I modified the IntControls function to make it relative to the camera (which took me ages) and also removed Keyboard support because I wasn’t going to use it.

IntControls function
local function IntControls(character, gamepad, camera)
	local Humanoid = character:WaitForChild("Humanoid")
	local Up,Down,Left,Right = 0,0,0,0
	local GamepadX,GamepadY = 0,0
	local Jump = false

	UIS.InputBegan:Connect(function(Key)
		if UIS:GetFocusedTextBox() then return end
		if Key.KeyCode == Enum.KeyCode.ButtonA and Key.UserInputType == gamepad then
			Jump = true
		end
	end)

	UIS.InputEnded:Connect(function(Key)
		if UIS:GetFocusedTextBox() then return end
		if Key.KeyCode == Enum.KeyCode.ButtonA and Key.UserInputType == gamepad then
			Jump = false
		end
	end)

	UIS.InputChanged:Connect(function(Key)
		if Key.UserInputType == gamepad and Key.KeyCode == Enum.KeyCode.Thumbstick1 then
			local X,Y = Key.Position.X,Key.Position.Y
			if X < 0.1 and X > -0.1 then GamepadX = 0 else GamepadX = X end
			if Y < 0.1 and Y > -0.1 then GamepadY = 0 else GamepadY = -Y end
		end
	end)

	RenderStepped:Connect(function()
		Humanoid:Move(camera.CFrame:VectorToWorldSpace(Vector3.new(Up + Down + GamepadX,0,Left + Right + GamepadY)), false)
		if Jump == true then
			Humanoid.Jump = true
		end
	end)
end