Best Ways to do a Camera Module

Hi, I was working at a Custom Camera Module and I’m thinking at the best ways of doing it, what ideas I have: To do a ray from the user camera to the mouse location and then use CFrame.new(pos,lookAt)

If you have better and easier ideas, tell me.

I don’t want the entire script

Using metatables may make the API look nicer.

[EDIT 1] Also, I’m assuming you know RenderStepped, correct?

[EDIT 2] Also, I think it’s best to utilize as much existing code for your camera module as possible.

yes, i know how to use RenderStepped but the biggest problem is, like in roblox studio with Left Click being pressed, you can move your camera around, how can i make something like that?

You would have to lock the camera using UserInputService

https://developer.roblox.com/en-us/api-reference/property/UserInputService/MouseBehavior/index.html

I think I would Mouse.Move instead of UIS.
DeltaY = change in Y pos (Mouse.Y)
DeltaX = change in X pos (Mouse.X)

Probably add deltas to the existing angles on the X-Z for DeltaX and Y for DeltaY
Maybe use cos, sin for the X-Z positions and sin for Y position.

Also note, Mouse.Origin is Camera’s position pointed to the Mouse’s 3d position.

1 Like