How to calculate the time it takes for alignposition to align to position?

Hello! I wanted to know if there is a way to calculate the time it takes for the AlignPosition constraint to align to the position it is supposed to align to?

1 Like

No easy way.

What do you need it for?

local Value = 0
    Value += 1 
    until Part.Position = ... -- (Part.Position - Part1.Position).Magnitude <= 5
    print("It took "..Value.." seconds for part to reach position")

Like this?

I think he meant he wants to calculate the time it would take before using it. A use case would be tweening something for the same amount of time the align position would take.

There are many factors that can be used to calculate the time taking for AlignPosition like MaxForce, MaxVelocity, and Responsiveness. Responsiveness should be the value that you might need to look into because MaxForce and MaxVelocity also rely on this value also. However, you will need to understand how Responsiveness works before calculating the time. According to the Roblox page, it said…

The mechanism for responsiveness is a little complicated, but put simply the higher the responsiveness, the quicker the constraint will try to reach its goal.

So so so, there is no easy way for this.

There is something you can do though, ‘Prediction’ You can build a data table that observe these values. Let’s say you attach the AlignPosition on a player, and a box behind him. You can observe those values, and WalkSpeed of the player, time it takes in total. Collect these data and create a linear regression or some kinds of statistic values from the data or even build an AI model that help you predicts the time that it will take before AlignPosition will try to reach its destination. It will be really good if someone already did it and publish it as a ModuleScript. A bit fancy here, but that is how it can be achieved based on what I know only. Of course there is no easy way since Roblox does not provide any direct approaches for this mechanism.

This can be used as a homing missile weapon to calculate how much time before the missile hit a helicopter, how cool is that just to think about it. Dang.

to do something after the contraint has reached the align position

yeah that is what I am looking for.

Alright. But besides that is there some kind of formula I can use or something?

I mean, you are the one who are responsible for finding that formula. This is only my idea though. So you can use ContextActionService or UserInputService to track when player moves. Let’s say that there is one part following that player using AlignPosition. When the player moves, you start tracking player movement and wait until the movement is completed, then you record the value of how long that the player moved, Responsiveness MaxForce, MaxVelocity, how far that the player moved. Then, you can track manually on how long does AlignPosition take to move to the destination. Finally, you can contruct your own formula for AlignPosition