#how do you make an object get to point A to point B in X amount of seconds?

8 messages · Page 1 of 1 (latest)

next sand
#

To be brief,

First, get the started position of the so called “line” of path you will use from point A to point B. Then get the second position, these can be represented with physical object if you choose, or they could be vectors if you want to not have to go through the process of making the objects.

Then make a lerp, connecting the start and end pins to their corresponding vectors.

If you know how to make delay counters than you can skip this next step.

Now, make a float variable and call it whatever you want, preferably “progress” because it is representing the “progress” of the travel. To make this you need to get an add chip and do the criss cross input thing that looks like an X where the output of the add goes into the input of the variable and the output of the variable goes into the add. This makes it so every time you execute into the variable, it adds a value to the chip. Now set it to the interval in which you want it to add to. The values need to range from 0-1. As a test, use 0.05 on the add.

Then let’s make an if gate, this is so if the variable equals 1, it stops the mechanism, add an equal chip and an if chip. Se the “else” input to go into the variable so if the value is not max, it continues with the flow of the cycle, and make the Boolean value of the if, the output of the equals, get the variable output and set it to the first pin of the equals, and set the second pin to a value of “1” as this should stop the mechanism when needed.

Now you need to add a delay, make a delay to where every <seconds> amount of seconds, it triggers the add. So make a delay that hits “run” off a button and starts the delay. On the “After Delay” pin, wire that to the if chip input, so that when it is done with the delay, it adds to the variable.

Now make a set position, this will go off of the variable set to set the position of the cube. Set the input of the set position to the output of the float variable you probably called “progress” as suggested

#

Now you wire the object needed to be moved to the object value if you have collected that. And the position will be connected to the output of the lerp and the progress pin will be the float variable

#

That should be it. Sorry if it was confusing, it’s 12:00 am so I’m tired

quiet goblet
#

Save both pos in a variable, put the variable into a lerp and 30hz it with whatever progress

#

30hz isn't alway 100% precise but yeah

#

We'll say 25 is average, then use 0.04 progress for 1 second

desert hearth
#

Update 30Hz (Delta Time) * Divide [1/x] where x is the time to reach 1 (when adding to a variable).

**Add that onto the Float Variable and follow Minecart's instructions. **

short jackal
#

Use lerp

The progress is between 0 and 1

So, just divide time by max time

If you divide CurrentTime by 2, it will take 2 seconds to get from start to end

Idk what the hell these answers were from, incredibly overcomplicated
@quiet goblet @desert hearth @quiet goblet @next sand

Edit:
To find current time, save Time Get Precise Seconds into a variable on start, and then subtract the current Time Get Precise Seconds by that variable, this will get you the amount of seconds since the variable was saved