Hey! I’m in the middle of making a FNaF styled game, and found a really cool feature on another game. I’m asking any scripture on how I’d make this:
https://gyazo.com/0009631dd0d88d02e5e63f4064d83df7
Notice how the camera moves with the mouse? that’s my question!
Thank you!
You can use RunService | Roblox Creator Documentation to position the camera every frame. Rotate it from some base rotation, based on the Mouse | Roblox Creator Documentation position.
Or, you could make the camera Camera | Roblox Creator Documentation Scriptable
, and just rotate it whenever the mouse moves.
When I say “rotate it”, I mean change its CFrame.
How would I do this? (Not saying provide the script, just provide a few more steps.) Sorry, I’m not the best scripter when it comes to the camera.
Most of those links have pretty detailed examples of different ways to rotate the camera.
But the second way, with a Scriptable
camera, goes something like:
- Set the
CameraType
to Scriptable
.
- Determine your “starting” CFrame. This could just be a part you place where you want the camera to be, and you can do
local startCFrame = workspace.Part.CFrame
or something.
- Bind a function to the
Mouse.Move
event that…
- Determines the offset of the mouse from the middle of the screen (like
Mouse.X - halfTheScreenWidth
), and…
- Sets the
Camera.CFrame
to startCFrame * CFrame.Angles(0, SOME_NUMBER * mouseOffset / halfTheScreenWidth, 0)
1 Like