Hello everyone, I saw this effect on a popular game (The Mimic), and I wanted to recreate it (The menu buttons following mouse). Although, I am not that good with coding and I was wondering how I could make this
EFFECT:
How would I go along with this?
I’ve thought of:
coding it in StarterGui with the GetMouse thingy
or I could make a BillBoardGui and put my buttons there.
If anyone can help me recreate the movement shown in the video, that would be greatly appreciated. Thank you!
What the code is doing is receiving the magnitude between the midpoint of the game window size and the mouse position relative, and rotating the camera according to the magnitude received.
Rather than code this up, let me explain it and break it down. The camera has been put in a live place in the game with a GUI overlaid on the screen. When the mouse moves, both the camera and the GUI shift slightly to create the motion effect. You probably know this much already. So, how is this done…
The menu on the left is a ScreenGui with a transparent background so just the text shows. The workspace.Camera is set to Enum.CameraType.Scriptable and it’s CFrame is set to that it is sitting in this field in front of this box. The Camera Subject is set to something in the distance, probably one of the doors to the tent which causes the camera to always point toward those doors.
Screen size is necessary to know relative position of the mouse in teh screen. Screen size is obtained via the Camera.ViewportSize.
As the mouse moves from the center of the screen, the camera is nudged slightly in the same direction by adjusting its CFrame while the ScreenGui is nudged in the opposite direction be adjusting its Position offsets. A polynomial function can be used if you want the shift to be non-linear.
It’s a nice effect and the setting is really nice as well. Very well done in that game.