local RelativeDirection = (getPosition() - self.UI.CoordinateSystem.AbsolutePosition).Unit
local Degrees = math.deg(math.acos(RelativeDirection.Y))
if math.sign(RelativeDirection.X) == -1 then
Degrees = 360 - Degrees
end
self.UI.DisplayVector.Arrow.Position = UDim2.new(0, 50*RelativeDirection.X, 0, 50*RelativeDirection.Y) + self.UI.CoordinateSystem.Position
self.UI.DisplayVector.Arrow.Rotation = -Degrees
local degPerSegment = 360 / 8
for i, v in ipairs(self.slots) do
if Degrees <= i * degPerSegment then
print(`selecting {i}`)
break
end
end
print(Degrees)
code example (mightve butchered it a bit bc im just writing on devforum)
local initalpos = mouse.Position
--name the variables whatever you want
mouse:GetPropertyChangedSignal("Position"):Connect(function(currentPos)
local tanA = initialpos/currentPos
local A = math.deg(math.arctan(tanA))
print(A) --should be the final value
end)
CORRECTION: arctan(1) = 0.7ish rads, just do math.deg(math.arctan(tanA))
no dude its a weapon wheel youre supposed to hover over the desired weapon…
its slower and less seamless if they have to open and click their desired weapon, and even then the buttons arent big so they might have trouble clicking
again, not seamless, they have to literally hover over the button, its supposed to be a quick action they dont have the time to make sure their mouse is hovering over the button
local RelativeDirection = ( self.UI.CoordinateSystem.AbsolutePosition-getPosition()).Unit
local Degrees = math.deg(math.acos(RelativeDirection.Y))
if math.sign(RelativeDirection.X) == 1 then
Degrees = 360 - Degrees
end
self.UI.DisplayVector.Arrow.Position = UDim2.new(0, 50*RelativeDirection.X, 0, 50*RelativeDirection.Y) + self.UI.CoordinateSystem.Position
self.UI.DisplayVector.Arrow.Rotation = -Degrees
local degPerSegment = 360 / 8
for i, v in ipairs(self.slots) do
if Degrees <= i * degPerSegment then
print(`selecting {i}`)
break
end
end
print(Degrees)