Discuss Scratch

Zparx
Scratcher
500+ posts

"lag" effect with path following between 2 sprites?

I'm wondering how I can make a sprite follow the y-position of another, while taking a small while to accurately line up with the coordinate. I've tried simple methods like

and


both of which still represent a good idea of what I'm trying to accomplish, yet do not function as intended. I hope someone can understand and is able to help ;p

Thanks!

Last edited by Zparx (June 12, 2013 14:56:28)

turkey3
Scratcher
1000+ posts

"lag" effect with path following between 2 sprites?

forever
if <([y position] of [sprite1]) > ((y position) + (3))>
change y by (3)
end
if <([y position] of [sprite1]) < ((y position) - (3))
change y by (-3)
end
if <(abs of (([y position] of [sprite1]) - (y position))) < (4)>
set y to ([y position] of [sprite1])
If you change those 3's to a higher number the sprite will try to match its y coordinate up quicker. I wrote this off my mind so sorry if it's a bit off

Last edited by turkey3 (June 12, 2013 15:50:03)

ErnieParke
Scratcher
1000+ posts

"lag" effect with path following between 2 sprites?

Here

Zparx wrote:

I'm wondering how I can make a sprite follow the y-position of another, while taking a small while to accurately line up with the coordinate. I've tried simple methods like

and


both of which still represent a good idea of what I'm trying to accomplish, yet do not function as intended. I hope someone can understand and is able to help ;p

Thanks!
I see what you need. It just takes a little twist of coding, which I'll show you:

when gf clicked
forever
change y by ((([y position v] of [Sprite to Follow v]) - (y position)) * (0.5))
Blank
I hope that this helps!

With regards,

ErnieParke

P.S. Out of curiosity, is this by chance for Ping Pong?

Last edited by ErnieParke (June 12, 2013 23:17:08)

dracae
Scratcher
1000+ posts

"lag" effect with path following between 2 sprites?

ErnieParke wrote:

Here

Zparx wrote:

I'm wondering how I can make a sprite follow the y-position of another, while taking a small while to accurately line up with the coordinate. I've tried simple methods like

and


both of which still represent a good idea of what I'm trying to accomplish, yet do not function as intended. I hope someone can understand and is able to help ;p

Thanks!
I see what you need. It just takes a little twist of coding, which I'll show you:

when gf clicked
forever
change y by ((([y position v] of [Sprite to Follow v]) - (y position)) * (0.5))
Blank
I hope that this helps!

With regards,

ErnieParke

P.S. Out of curiosity, is this by chance for Ping Pong?
Erm… That doesn't really work…
Here's (in my opinion ) a wonderful script!

Hope I help!

EDIT: wrote:

Oh sorry! D: ErnieParke, your way works great! I just read it wrong… XD

What ErniePark was saying was similiar to this:

Last edited by dracae (June 13, 2013 01:44:21)

Powered by DjangoBB