Hello, I have a math question here I could probably solve when I get refreshed, but I’m out of ideas right now.
I have a tween, and in that tween it will move the position of Part1 to Part2, I want to change the tween’s time depending on the Part1 - Part2 length so that the tween isn’t super slow if the parts are close to each other or super fast if they are far away.
I’d check for the magnitude, but would I need to check for alpha or something like that?
But I don’t know how to apply “relativity” to know an object’s instant speed (and I’m also using tweenservice)
The only way I’d know to check for the speed is once the object has already moved not before
You can use speed = distance / time that you will have learnt in school. We can rearrange for time like so: time = distance / speed. Distance is (Part1.Position - Part2.Position).Magnitude and speed is a predefined constant:
local Speed: number = 1 -- Studs per second
local Time: number = (Part1.Position - Part2.Position).Magnitude / Speed
Simply plug the time into the TweenInfo and away you go.
Edit: Got the order wrong in the rearrangement sorry.
alright thanks guys both of you have helped me, the only solution I could come in my mind was to get the delta of position divided by the delta of time but that would be done after the object has been moved (so I couldn’t change the tween)
but thanks bobby for the speed variable I didn’t think about that
Both of you are correct but I can just tick one answer