[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: 101
Reputation: 3,918

Post » Wed Dec 12, 2012 2:04 am

This maybe help

http://www.scirra.com/forum/follow-smoothly_topic47050_post294672.html#294672
B
21
S
5
G
2
Posts: 82
Reputation: 3,032

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
41
S
17
G
17
Posts: 2,247
Reputation: 17,436

Post » Wed Dec 12, 2012 12:34 pm

what is lerp? how do we use lerp?
B
22
S
1
Posts: 23
Reputation: 2,604

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
276
S
103
G
84
Posts: 7,292
Reputation: 83,106

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: 101
Reputation: 3,918


Return to How do I....?

Who is online

Users browsing this forum: CJacobsSA, Magistross, Mato and 7 guests