How to move the camera with keyboard and mouse like the humanoid?

I have a camera set to “scriptable”.
How to move it with mouse and keyboard exactly like when the camera subject is the humanoid?
I mean, to move the camera with WASD keys and using the mouse movements and buttons, exactly like Roblox do with the character.
This because the current mouse and keyboard are bind to the humanoid.
Do I have to recreate all the movements from scratch by myself?
Or is there a way to reuse the current Roblox functions that moves the humanoid to avoid a rework?
If not, where could I find a ready made code for that?

1 Like

You can hook onto the existing movement system, e.g. get the MoveVector from the PlayerController rather than encoding the keybinds. This would allow you to move the Camera’s position in 3D space using wasd/udlr and even mobile controls. If not, you would need to bind those keys/events through UserInputService and add the direction vector to the camera’s position relative to its orientation.

In regard to moving the camera rotionally, you once again could look through RBX’s CameraModule and strip parts off. However, having looked at it, it’d be far quicker for you to code it yourself by binding Mouse events to UserInputService - finger tracking is slightly more tricky, but there is some fairly decent documentation for this on the Wiki. You can then add the delta positions of the mouse/fingers to the camera’s yaw and pitch alongside updating its position with the aforementioned steps.

Do you have to recreate it all yourself? Probably not, no - I would imagine there is a free model online with something similar. I imagine it would be called something like “free camera”. However, I would recommend that you do try to do it yourself if you’re trying to learn how to script. Check the RBX wiki for the terms I mentioned above, and look at the PlayerController and CameraController modules roblox uses for its own characters - you should be able to get something from it, even if it fails.

1 Like

Tks. Found something promising: