Camera direction arrow will not move

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to make an arrow cursor point in the direction the camera is moving, similar to this: https://gyazo.com/34e5bc057680f1ff9d06c1b13d51f8ac

  1. What is the issue? Include screenshots / videos if possible!

The arrow points off to the corner and barely budges when I move the camera.
image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried a variety of trigonometry functions, none of them seem to work.

My current script:

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera

local lastlookvector = cam.CFrame.LookVector

local UIS = game:GetService('UserInputService')

UIS.InputChanged:Connect(function(input)
	if input.UserInputType==Enum.UserInputType.MouseMovement  then
		local movementX = input.Delta.X
		local movementY = input.Delta.Y
		
		local offsetpoint1 = (cam.ViewportSize.X/2+movementX)
		local offsetpoint2 = (cam.ViewportSize.Y/2+movementY)
		local angle = math.atan2(offsetpoint2,offsetpoint1)
		local convertedangle = ((angle/math.pi)*180)
		print(math.deg(angle))
		script.Parent.Rotation=convertedangle
	end
end)

I figured it out. Here’s my new script:

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera

local lastlookvector = cam.CFrame.LookVector

local UIS = game:GetService('UserInputService')

UIS.InputChanged:Connect(function(input)
	if input.UserInputType==Enum.UserInputType.MouseMovement  then
		local movementX = input.Delta.X
		local movementY = input.Delta.Y
		
		local offsetpoint1 = (movementX)
		local offsetpoint2 = (movementY)
		local angle = math.atan2(offsetpoint2,offsetpoint1)*(180/math.pi)
		script.Parent.Rotation=angle+180
	end
end)
1 Like

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