Basically I just want some help pointing me where to go as I am not that good at cameras & stuff, I want to recreate a camera effect seen in many games such as seen in HELLMET,
When you first open the game the effect shows on the menu where the camera slightly leans towards the cursor, creating this effect that is like watching a video that was recorded holding a camera IRL,
This effect can be seen in some realistic first person shooters as realistic camera shake that mimics what we see and how when our chest expands from breathing we grow (not very much like barely) taller,
Anyways I am going nowhere so how can I recreate this effect where the camera leans towards the cursor?
Well first you’d need to get the normalised position of the mouse (from the centre).
Lucky for you, I already have that code on hand:
function getNormalisedMousePosition() : Vector2 -- Returns the mouse position normalised to the screen
local mouse = Players.LocalPlayer:GetMouse()
local rawVector = Vector2.new(mouse.X, mouse.Y)/Vector2.new(mouse.ViewSizeX, mouse.ViewSizeY)
return Vector2.new(math.clamp(rawVector.X,0,1),math.clamp(rawVector.Y,0,1)) -- Must be wrapped in math.clamp due to some random bug
end
(Ignore that last comment, I haven’t gotten round to figuring out the problem with it, but it works perfectly fine)
Now, you just need to lerp the camera’s rotation so it offsets from the default rotation. Take the default rotation, and add an offset rotation onto the X/Z and Y axes, multiplied by the normalised X and Y position of the mouse respectively. Then use a lerp function to smoothly animate the camera’s current CFrame towards that new CFrame.
I have actually used this exact same code before as I found it on a different post but my issue is that it does not stop along the edges of the screen, So you can just spin and do barrel rolls which is not what I want at all and I can’t even use it that way because it would break my menu as I need it to be seen from a certain perspective.
Edit: Didn’t read through all the code but I still don’t know how to implement this