Moving with mouse + lag

Get help using Construct 2

Post » Tue Nov 08, 2011 8:39 pm

How do I move an object with the mouse that has a slight lag before catching up to the mouse? Something like the tank in this game?

http://www.frooga.com/Games_Folder/shoot/alien-invasion.html
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Tue Nov 08, 2011 8:55 pm

Set the object's x and y positions every tick to..

lerp(object.x,mouse.x,n*dt)
lerp(object.y,mouse.y,n*dt)

Where n is the speed at which the object moves towards the mouse.

You might also be able to use "move at angle".

Also I'm not sure if C2 has lerp yet...probably does..
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Wed Nov 09, 2011 9:52 am

I don't think it does, does it?
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Wed Nov 09, 2011 10:26 am

Yeah, it does.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Wed Nov 09, 2011 2:09 pm

Thanks!
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Wed Nov 09, 2011 7:32 pm

Just tried it and it works brilliantly! Much appreciated Tokinson. :)
B
72
S
25
G
9
Posts: 382
Reputation: 10,649


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests