Is this possible to achieve with constraints?

Basically, I’m trying to figure out the best way to move a model to bricks that act as the nodes or position goals for its path.

I thought of originally tweening the model to each point’s position, however, this would be rough mainly because I want the model to be moving at a linear speed, and depending on the distance of the model’s current position to the node it’s moving to, the speed of the tween will change.

I just wondered, is this behavior possible to achieve using some combo of constraints?

On top of this, I also need to adjust the model’s rotation to animate it as it moves. This also gives me more reason to avoid tweening the model.

Not really sure here…thanks!

You can use some maths to make linear animation. Simply just lerp the position from the current position to the end position using this formula:

local Position = PartPosition
local StartTime = tick()
RS.Heartbeat:Connect(function()
    Position:Lerp(TotalLength / (tick() - StartTime))
end

You can always change the position and it will keep lerping.

1 Like

If I recall correctly, Tweening also modifies the CFrame. You would only need some basic physics knowledge to achieve a constant speed:

velocity = distance / time

In this case, you want to keep a constant velocity throughout all tweens, and we can get the distance using the .Mangitude() method of a Vector3. Our dependent variable would then be the time.

time = distance / velocity
Now you assign the velocity you prefer as a constant, let’s say, 20 studs/ second. Next, check your initial and final positions using Vector3.Magnitude(). Divide This value by your velocity and you get the time value for your Tween.

Enjoy!

2 Likes