How can I make a movement system that supports a 2D camera?

I want to make a 2D game on roblox and so far I have made the camera and I just have this issue.
I don’t know how I can make movement that supports the 2D camera. I have tried so many things, such as using context action service (didn’t work properly), moveTo() (didn’t work properly too) and I’ve been stuck to this infinite loop trying to either fix my first idea or find a new one.
What I’m looking for isn’t a script, just an idea that will work. That’s all, thanks for reading this.

1 Like

Go on the roblox document i’m not sure but i think he has your solution

Yea but, what do I need to read there?

but when you say a 2D camera do you do that?

camera.focus = workspace.part.focus

if yes you just can move the part where you want and do this:

while true do
workspace.part.position =, position(), position())

I want to move the player, not a part.

So when player move the 2D camera move also?

Okay, so just for my information: Is a 2D camera just a camera being used to display the world in a fixated offset and orientation, or is it a separate instance class I didn’t find out in my past few years of scripting?

Will the script of the camera help you understand? Because I didn’t make it my self and can’t explain very well.

Have you tried using Player:Move? You can probably bind context actions/user input so that the a and d/arrow keys move the character sideways with that function.

I tried using it, but it just instantly teleports the player to a position.

How exactly does that happen? Are you sure you’re not using Model:MoveTo? As in moving the character using that method, character:MoveTo(pos)

At first, I used moveTo, and I want to see the different between that and move. But when I did move, it just did the same thing as moveTo

Player:Move should tell the character’s humanoid to move in a direction specified by the vector you used as an argument. Something like this code would make the player walk forward, just from code:

local Players = game:GetService("Players")

local player = Players.LocalPlayer

-- make the player's character walk forward relative to the camera
player:Move(, 0, 1), true)

No need to access the character or their humanoid. Roblox’s default control module uses this too.

1 Like

Ill try this and see if it works

Do you know how I can disable all player movement so the script can work?

My best guess is setting StarterPlayer.DevComputerMovementMode to Enum.DevComputerMovementMode.Scriptable. If that doesn’t work, trying forking the player’s PlayerModule (by copying it from Players[your player].PlayerScripts in the explorer when the game is running) and delete or otherwise disable the ControlModule.

It might be a good idea to do the same for StarterPlayer.DevTouchMovementMode with the corresponding enum.

Ok, it actually works. Ill do some keybinds and after I’m done, ill inform you. Thanks a lot!

1 Like