How could I recreate this effect (image follows mouse making it look 3D)

So I have NO idea how I would go about doing this at all lol :sweat_smile:

the effect - 2022-06-09 20-31-35

if someone could help me create i would be veri happy. Thanks in advanced

EDITED AFTER SOLUTION WAS FOUND :
the solution leans to the right a lot because it thinks the center of the screen is farther to the left, so I found that replacing

local X = InputObject.Position.X - (ScreenGui.AbsoluteSize.X / 2) + (ViewportFrame.AbsoluteSize.X / 2)
local Y = InputObject.Position.Y - (ScreenGui.AbsoluteSize.Y / 2) + (ViewportFrame.AbsoluteSize.Y / 2)

with

	local middleOfScreen = Vector2.new(workspace.CurrentCamera.ViewportSize.X / 2, workspace.CurrentCamera.ViewportSize.Y / 2  - (game:GetService("GuiService"):GetGuiInset().Y/2))
	print(middleOfScreen)
	
	local X = InputObject.Position.X - middleOfScreen.X
	local Y = InputObject.Position.Y - middleOfScreen.Y

fixes this problem

This would only be possible with a SurfaceGui/BillboardGui since ScreenGuis are purely two dimensional (excluding viewports).

You could stick a very thin part with a decal on it inside a ViewportFrame, if you must stick with GUIs.

Then just detect mouse movement and rotate the part some angle amount using the mouse x and y screen Position.

https://gyazo.com/cc095dd0d7a2525bcfcd33de165e51b9

I came up with this, the mouse’s cursor can be changed upon entry/exit of the viewport frame through its ‘MouseEnter’ and ‘MouseLeave’ signals.

local Enumeration = Enum
local Game = game
local TweenService = Game:GetService("TweenService")
local Script = script
local ScreenGui = Script:FindFirstAncestorOfClass("ScreenGui")
local ViewportFrame = ScreenGui:FindFirstChildOfClass("ViewportFrame")
local Part = ViewportFrame:FindFirstChild("Part")

local function OnInputChanged(InputObject, GameProcessed)
	if GameProcessed then return end
	if InputObject.UserInputType ~= Enumeration.UserInputType.MouseMovement then return end
	local X = InputObject.Position.X - (ScreenGui.AbsoluteSize.X / 2) + (ViewportFrame.AbsoluteSize.X / 2)
	local Y = InputObject.Position.Y - (ScreenGui.AbsoluteSize.Y / 2) + (ViewportFrame.AbsoluteSize.Y / 2)
	X = (X - 210) / 30
	Y = (Y - 210) / 30
	local Tween = TweenService:Create(Part, TweenInfo.new(0.2, Enumeration.EasingStyle.Linear, Enumeration.EasingDirection.Out), {Orientation = Vector3.new(Y, X, 0)})
	Tween:Play()
end

ViewportFrame.InputChanged:Connect(OnInputChanged)

Here’s the place file if you need to inspect further.
Gui.rbxl (29.0 KB)

6 Likes

that works perfectly, tysm!!!

This would be cool to, if the mouse was not inside of the box, like somewhere else on the screen… there was a delay like 4 seconds, and then the inner area would reset to a straight perfect position, like when it started…

instead of when you are out of it, it is off centered …