Discuss Scratch

DovaScratcher
Scratcher
45 posts

Make an sprite stick to a sprite

I've made a basic platformer, and I want a sprite to follow the playable sprite around, and by that I mean constantly stick to the sprite. I have tried several methods, but each one has a discernible delay. Could anyone help me?

Methods I've tried:
forever
go to [sprite1 v]
end

forever
set x to ([x position v] of [sprite1 v])
set y to ([y position v] of [sprite1 v])
end

forever
change x by (xspeed)
change y by (yspeed)
end
I've also tried the above by placing them in custom scripts, but that has no difference either. The third example's xspeed and yspeed are based on the movement of sprite1.
ZozaTech
Scratcher
500+ posts

Make an sprite stick to a sprite

when green flag clicked
forever
go to [ mousepointer ]
wait (0.000001) secs
go to [sprite1]
end
ZozaTech
Scratcher
500+ posts

Make an sprite stick to a sprite

Or try
when green flag clicked
set [pos] to [1 ]
when green flag clicked
forever

if <(pos) = [1]> then
broadcast [move]

end

end
Okay. In the sprite1 put this
when I receive [move]
forever

go to [the other sprite]
end
I think your problem is that the things you tried were supposed to go in the other sprite. Sprite 1 I believe.
DovaScratcher
Scratcher
45 posts

Make an sprite stick to a sprite

I tried both methods, but the second has the same result, and the first just causes it to swap between the mousepointer and sprite1 visibly. The script is for sprite2.
ZozaTech
Scratcher
500+ posts

Make an sprite stick to a sprite

Try all of your methods(pick one) but instead of putting it into this sprite, put it to the other sprite.
deck26
Scratcher
1000+ posts

Make an sprite stick to a sprite

If it seems slow it may be because of other things in your project. The methods you're trying should generally be fast enough.
jamy_hensley
Scratcher
100+ posts

Make an sprite stick to a sprite

I removed the
go to [mouse-pointer]

and the

wait () secs

In the script. The gun sticks to the player

Note that if you put the code in custom block which don't refresh, you will have no delay at all.
DovaScratcher
Scratcher
45 posts

Make an sprite stick to a sprite

I honestly have no idea what's up with the project

All I have is a platforming sprite, and a platform sprite. The Platform sprite has no script, and the platforming sprite has your basic platforming script.

My project is below. I want Gun to stick to player.

https://scratch.mit.edu/projects/73716360/#player

deck26
Scratcher
1000+ posts

Make an sprite stick to a sprite

Try this

After the call to TouchedPlatform add a ‘broadcast follow’. Then in the gun sprite get rid of the current script and tell it to go to player when it receives follow.

You might need to do the same after a Walk.
DovaScratcher
Scratcher
45 posts

Make an sprite stick to a sprite

Thanks, it worked just after I put it after TouchedPlatform. Thanks for the help!
aljay0578
New Scratcher
1 post

Make an sprite stick to a sprite

hiiiiii
Charles12310
Scratcher
1000+ posts

Make an sprite stick to a sprite

aljay0578 wrote:

hiiiiii
Please do not necropost. This topic is about 2 years old, and the problem has been solved. If you need more help, please make another topic.

Powered by DjangoBB