# How do I: Smoothly, continuously move object to position

Get help using Construct 2

### » Fri Nov 25, 2016 7:03 pm

Hi all! :]]

I don't know if this is even possible. But I have thought a lot about it, and I can't seam to figure it out, so I thought I might ask if anyone else can.
I'm making a game where you control a spaceship, and I want the spaceship to Follow the cursor around when the mouse is moved.
Like a Bullet behaviors that has an event that always sets angle to Mouse.X and Mouse.Y.

Also I'm aiming towards an "Asteroids"-feel to the movement. Meaning that ideally, the ship should accelerate, and decelerate smoothly, and if the cursor is moved, the ship should adjust to the cursors new position. Sort of like a custom movement which has an event that continuously accelerates the ship towards Mouse.X and Mouse.Y.

On top of this the ship needs to adjust as to "hit" the cursor. All I can make it do is fall into an orbit around it. (which makes sense considering I don't know how to compensate for current speed and angle ).

If this requires very difficult math or something, I'm willing to google around and try to understand your calculations. But I can't for the life of me figure this out.
Any help would be greatly appreciated. Even as to say that this can't really be done. Then I would at least be content in giving up.
B
6
S
2
G
2
Posts: 33
Reputation: 891

### » Fri Nov 25, 2016 11:43 pm

Here you go:

I included two variants:
• a lerp variant which emulates acceleration by using lerp
• a custom movement variant which is quite complicated because of all your needs ;)

The .capx is fully commented, I hope you understand everything and I also hope, I understood correctly what you need.
In case you have questions, don't hesitate to ask.
Last edited by randomly on Fri Dec 30, 2016 12:55 am, edited 1 time in total.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

### » Thu Dec 01, 2016 4:15 pm

Thats you for taking the time to help randomly. (That's a nice sentence ).

The first example can't account for collisions properly, due to it setting position. (And also didn't have the "Thrusters in space" feel to it.)
The second movement sometimes didn't move at all for several seconds and didn't hit the cursors position.
So I couldn't adopt any of those movements directly.

But I did get a few ideas and learned a few things from them though.
For starters, even though I had read the whole manual, I had never actually used lerp, and then I guess I must have forgotten about it, Because I just recently "Solved" this by using something like (A*C+B*D)/(C+D) instead of lerp.

Experimenting with your second movement made me get the ideas that I then used to manage to build the movement I was after. In the end though. I systematically replaced all the lerp stuff I had in it. But it was an important stepping stone.

I provided the "finished product" that I will implement into my game. In case anyone is interested.

Thanks again! <3
B
6
S
2
G
2
Posts: 33
Reputation: 891

### » Sat Dec 24, 2016 10:06 am

Do you still have this capx fire shared somewhere? The link above is busted.

Thanks!
B
18
S
9
G
3
Posts: 41
Reputation: 3,198

### » Fri Dec 30, 2016 12:56 am

"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091