follow the mouse with lag

Get help using Construct 2

Post » Wed Oct 19, 2011 7:23 am

how do i get a sprite to follow the mouse with some sort of lag

i know this works, but it is very rigid:

system -> every tick --> set sprite Y to Mouse.Y

any suggestions on how to get the sprite to lag behind the mouse a bit and when the movement stops the sprite "settles" into position
???
B
16
S
2
G
1
Posts: 43
Reputation: 1,473

Post » Wed Oct 19, 2011 8:10 am

http://db.tt/p9xWaV6R

How's that? It took a couple events and an array to make it happen, but it seems to get the job done. As far as I can see there's no way to make the main cursor invisible, though...SullyTheStrange2011-10-19 08:11:16
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Wed Oct 19, 2011 1:39 pm

Can you decrease the speed of the sprite when it gets x number of pixels from the mouse?

distance(sprite.X, sprite.Y, Mouse.X, Mouse.Y) <= 100
Set sprite speed

Going off memory here. Am at work and no access to test it out. Lol
B
22
S
9
G
3
Posts: 202
Reputation: 3,645

Post » Wed Oct 19, 2011 2:29 pm

Thanx. I'll try them both out later today
B
16
S
2
G
1
Posts: 43
Reputation: 1,473

Post » Thu Oct 20, 2011 10:24 am

it depends what you want.

Make the object have a 'bullet' behavior.

If you want it to just move towards the mouse, just set the bullet speed to whatever you want and then every tick set the angle towards position of mouse_x, mouse_y.

if you want it to move at speed relative to its distance from the mouse, do the same as above, but every tick set the bullet speed to distance(object.x,object.y,mouse.x,mouse.y) / modifier + modifier

B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400


Return to How do I....?

Who is online

Users browsing this forum: dieblume86, Kagubro and 2 guests