Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Make an sprite stick to a sprite
- DovaScratcher
-
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:
Methods I've tried:
foreverI'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.
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
- ZozaTech
-
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
-
500+ posts
Make an sprite stick to a sprite
Or try
when green flag clicked
set [pos] to [1 ]
when green flag clickedOkay. In the sprite1 put this
forever
if <(pos) = [1]> then
broadcast [move]
end
end
when I receive [move]I think your problem is that the things you tried were supposed to go in the other sprite. Sprite 1 I believe.
forever
go to [the other sprite]
end
- DovaScratcher
-
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
-
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
-
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
-
100+ posts
Make an sprite stick to a sprite
I removed the
and the
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.
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
-
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

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
-
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.
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
-
45 posts
Make an sprite stick to a sprite
Thanks, it worked just after I put it after TouchedPlatform. Thanks for the help!
- Charles12310
-
1000+ posts
Make an sprite stick to a sprite
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. hiiiiii
- Discussion Forums
- » Help with Scripts
-
» Make an sprite stick to a sprite