[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,886

Post » Wed Dec 12, 2012 2:04 am

This maybe help

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

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
36
S
16
G
16
Posts: 2,223
Reputation: 16,646

Post » Wed Dec 12, 2012 12:34 pm

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

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
262
S
93
G
55
Posts: 7,150
Reputation: 67,069

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,886


Return to How do I....?

Who is online

Users browsing this forum: 20170217, alimuqaddas, Lancifer, Zion and 2 guests