i need someone to help me with an equation for this tween.
i have a needle gui that need to move at a given speed but not slow down as it gets closer to its goal
local speed = 10
local function spin(direct)
direction = direct
local Editrection
if direct then
Editrection = Enum.EasingDirection.In
elseif not direct then
Editrection = Enum.EasingDirection.Out
end
if direct == "Died" then
failed()
end
local distance = (neddle.Rotation - mid:FindFirstChild("point").Rotation)
print(distance)
local goal = {Rotation = mid:FindFirstChild("point").Rotation + 10}
local Info = TweenInfo.new((distance)/speed,Enum.EasingStyle.Linear,Editrection)
local needle = tweenservice:Create(neddle,Info,goal)
needle:Play()
--[[if distance > then
failed()
end]]
end
local function spin(direct)
direction = direct
local Editrection
if direct then
Editrection = Enum.EasingDirection.In
elseif not direct then
Editrection = Enum.EasingDirection.Out
end
if direct == "Died" then
failed()
end
local distance = (neddle.Rotation - mid:FindFirstChild("point").Rotation)
print(distance)
local tweentime = distance/speed
print(tweentime)
local goal = {Rotation = mid:FindFirstChild("point").Rotation + 10}
local Info = TweenInfo.new(tweentime,Enum.EasingStyle.Linear,Editrection)
local needle = tweenservice:Create(neddle,Info,goal)
needle:Play()
--[[if distance > then
failed()
end]]
end
Are you playing this tween/calling this function repeatedly?
Given its travel is linear and the duration parameter isn’t changing, the only thing that could make it go slower is if the tween plays again from a lesser distance to its target, thus it won’t need to move as fast to reach the goal of this new tween.
ok then you need some different math to calculate the distance. You need to calculate radians and convert to degrees. And the code should look the same just remove the .position parts on both of them as well as the .magnitude at the end.
if your thing is moving too fast then decrease the speed variable.
oh so the way i have this set up is that the goal is the rotation of the point (the yellow dot)
and the tweens purpose is to move it to that goal but the issue I’m having is the time. the tween slows down once it reaches its goal or if the point is closer to the needle it will go slower and the only other option i had for moving it was a while loop witch lags on the phone