Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is the meaning of the code below? Relate to how Part is move by CFrame

Asked by 8 years ago

CFrame = Part.CFrame + (Direction * Increment) wait( (Time/Mag) * Increment )

The link to the wiki tutorial is here > [(http://wiki.roblox.com/index.php/Part_sliding)]

I try to understand what's the tutorial says but the code does not make sense to me

0
Can you communicate the code to me how it works? MinHoang 49 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

Basically, what is going on with that part of the code is that Direction is a unit vector value, which means it is pointing to where the door will move. Increment is how much you want the door to move in that direction.

Direction*Increment is essentially a distance in a direction with the length of the increment

Part.CFrame + (Direction*Increment) means that part's position will have the position of the direction added to it's own position resulting in the part moving.

wait((Time/Mag)*Increment means that the Time it will take to move the part will be divided by the Distance between where you want the part to be and having the Increment you move it by multiplied to that value since you count up by that increment.

In order for the loop to take the proper time you want it to take, the time needs to be divided by the distance and multiplied by the increment since you use that increment to count up to that magnitude.

Ad

Answer this question