[How?] Make a sprite follow the player

Get help using Construct 2

Post » Wed Dec 12, 2012 1:46 am

Hi guys, I'm new at the Scirra community. Pleased to meet you!

I want to make a sprite follow the player.

When the player's sprite touches the other sprite, the latter starts following it's movements.

I tried to do the following:

Created an instance variable boolean called "caught"

And then:



But it doesn't work. the "ovo" sprite starts walking without the player sprite touching it. ;/

I'd like to ask for your help.

Thanks in advance!

B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Wed Dec 12, 2012 2:04 am

This maybe help

http://www.scirra.com/forum/follow-smoothly_topic47050_post294672.html#294672
B
16
S
5
G
2
Posts: 76
Reputation: 2,885

Post » Wed Dec 12, 2012 2:15 am

Come on people ! Use Lerp !
Sprite : Set Position to : (lerp(Sprite.X ,Player.X ,2*dt),lerp(Sprite.Y ,Player.Y ,2*dt))
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Wed Dec 12, 2012 12:34 pm

what is lerp? how do we use lerp?
B
21
Posts: 23
Reputation: 2,429

Post » Wed Dec 12, 2012 3:15 pm

In the how do I FAQ you you can find several detailled explanations of lerp (the system expression) as well as an example of a companion that follows a sprite.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sat Dec 15, 2012 5:47 pm

Thanks guys, I will take a look at that thread and the game example!
B
12
S
6
G
3
Posts: 100
Reputation: 3,836


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], spcsmrf and 24 guests