# SOLVEDHow to make an instance move a certain distance over a certain period of time?

#### Tbug20

##### Member
v2.3.1.409

Hi, I was wondering if there's an easy way to make an object move a certain distance or to a certain point over a certain period of time, kinda like the "glide" block in Scratch. It's a pretty simple movement, and I can't for the life of me figure out how to do it. Anyone know a fast and easy way?

#### Slyddar

##### Member
There is a function called move_towards_point(), which you can call to achieve this. It's a simple function but requires a calculation with time to find the speed to move at. Also it only moves towards a point, you still need to stop it.

So to find the speed to travel at you need to work out the distance / time, so we can create a function which will take the position you want to move to, and the time you want it to happen in, so we can calculate the speed to use in the function. I've created an o_glide object to demonstrate, and added this create, step and alarm event, as well as the glide script which sets an alarm to stop the object once the time has expired. Basically when the mouse is held the time variable counts up. Once we release that time is applied to work out the speed.

Create
Step
Alarm0
Glide Script

Last edited:

#### Tbug20

##### Member
There is a function called move_towards_point(), which you can call to achieve this. It's a simple function but requires a calculation with time to find the speed to move at.
What's the DnD equivalent of move_towards_point()?

also what a coincidence, this is actually for a game im making using your platformer tutorial lol

#### Slyddar

##### Member
There is no DnD equivalent. Many times in DnD you need to use the function call codeblock to apply a function.

haha, nice coincidence. Hope you're enjoying it

#### Tbug20

##### Member
There is no DnD equivalent. Many times in DnD you need to use the function call codeblock to apply a function.

haha, nice coincidence. Hope you're enjoying it
Whenever I use the function call block to move the object, the object no longer appears. when I loop it so that it goes bak and forth, the entire game freezes up upon opening. What's going on?

#### Slyddar

##### Member
Not sure what you are doing, but you only need to call the glide function once, and just supply an x, y and a time. The demo in the code above was just to show how it works. You will need to adjust what is happening to how you want to use it.

So are you trying to move the object you are moving back and forth between 2 points?

#### Tbug20

##### Member
So are you trying to move the object you are moving back and forth between 2 points?
Yes, and I've figured it out for the most part, but for some reason it'll go far up and to the left and back before doing what I want it to. I have screenshots of all my code and a video of what is happening.
video: