Rotating Cursor with Inertia

What I want to achieve:
I’m attempting to make a fun cursor for the game with the same functionality as shown in this video
SpinMyCursor! Rotate your mouse cursor to the direction you move it - YouTube

I want the cursor to be able to rotate (point) in the direction the player is moving the mouse. I don’t care about the ablity to have animated cursors, or being able to change them.

What solutions have you tried so far?
I’ve tried using a series of differently rotated images and changing the player’s cursor image when it’s moved in a specific direction but it’s choppy and not very fluid.

1 Like

Animated cursor tutorial here.

In my question I stated that i did not care for the animated cursor nor the abality to change the cursor. I would like the cursor to carry inertia and rotate around the “tip” when the mouse is moved.

Pretty easy to do.

Turn the mouse icon off, then use an ImageLabel to be a fake mouse icon.

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local Cursor = script.Parent
local Last = Vector2.new(0, 0)

local function UpdateCursor()
	local Position = UserInputService:GetMouseLocation()
	local Delta = Last - Position
	
	if Delta.Magnitude < 5 then return end
	
	Cursor.Rotation = math.deg(math.atan2(Last.Y - Position.Y, Last.X - Position.X)) - 90
	Cursor.Position = UDim2.new(0, Position.X, 0, Position.Y)
	
	Last = Position
end

UserInputService.MouseIconEnabled = false
RunService.Heartbeat:Connect(UpdateCursor)

then just rotate the mouse to face the direction of where it moved to if the distance it moved is greater than a pre-set amount of pixels. I chose 5 but you can choose anything.

This does not rotate the frame about the tip of the mouse, but the effect is good enough when rotating from the center due to the size of the image being small.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.