Hey, I was wondering how I could make it so that when you move your mouse across the screen, the x and y vector of your camera moves in the direction of your mouse. Like Vesteraria or Boxing league. I also want it to have a max moving distance so you can’t keep your mouse at the edge of the screen and have it so your camera is moving forever. I also want it to feel like it has an elastic feel when you move it a lot.
Sorry for the bad grammar lol.
This tells you a lot about customizing cameras with out many scripts(not as good)Customizing Camera
This is also a better tutorial about it although more advancedHere
Hope that helped
Sorry this did not help, I have already read this article and do not know how to achieve what I want.
Well. I don’t know exactly how they did it but I can take a guess.
- Create an original CFrame. The CFrame when the mouse Position is in the center of the screen
- Get the MousePosition
- Get the ViewportSize and divide it by two since you will need it to translate the mouse to the center of the screen and not relative to the top right.
- Offset or rotate the CFrame by the
MousePosition - (ViewPortSize/2)
Note: I created this a few months ago and I used CFrame Lerp to smooth it all out.
-- Of course this is all in a RenderStepped Loop
Camera.CFrame = Camera.CFrame:Lerp(
CFrame.lookAt(
ScreenPart.Position + (ScreenPart.CFrame.LookVector * 13),
ScreenPart.Position -- Original CFrame
) * CFrame.new(0,0,0,rad(MouseLocation.Y),rad(MouseLocation.X),0,10), -- Rotating(you can use CFame angles or an offset CFrame here too!)
DeltaTime * 5
)
Thank you, but I don’t want you to be able to look behind yourself or like have a 360 view, I want a min and max camera movement. Also, I do not know how to get the mouse position, so could you please make the top part of the script with the variables and other stuff, thanks.
Use math.clamp to get a min and max distance.
ok, i’ll look into it (30*********)
Well you shouldn’t really have to clamp anything as the mouse is already limited to the size of your screen.
If your camera movent is too sensitive you can simply use a multiplier
MouseLocation /= 8 -- Mouse 8 times less sensitive
Getting the Viewport size and mouse location is actually pretty easy. It’s one line of code. I suggest you look at the docs as there are a bunch more functions that are useful for future reference.
Camera
Camera.ViewportSize
UserInputService
UserInputService:GetMouseLocation()