Discuss Scratch

JungleHornet
Scratcher
5 posts

Gliding to my mouse

Is there a way to make a sprite glide to my mouse at a set speed until it gets to my mouse whenever I press space?
mrcreatorluigi
Scratcher
1000+ posts

Gliding to my mouse

I think this script might work:

foreverifkeyspacepressed?thenglidesecstomouse pointer
JungleHornet
Scratcher
5 posts

Gliding to my mouse

mrcreatorluigi wrote:

I think this script might work:

foreverifkeyspacepressed?thenglidesecstomouse pointer
the problem with that is that would glide to my mouse over a second, going different speeds depending on how far away my mouse is. I want something to gile to my mouse at the same speed every time, regardless of how long it would take to get there.
JungleHornet
Scratcher
5 posts

Gliding to my mouse

nevermind
supergamer10000
Scratcher
1000+ posts

Gliding to my mouse

JungleHornet wrote:

nevermind
Did that work?
JungleHornet
Scratcher
5 posts

Gliding to my mouse

supergamer10000 wrote:

JungleHornet wrote:

nevermind
Did that work?
no i just decided to go with a different movement system in my game.
AwezomeXD
Scratcher
100+ posts

Gliding to my mouse

JungleHornet wrote:

supergamer10000 wrote:

JungleHornet wrote:

nevermind
Did that work?
no i just decided to go with a different movement system in my game.
Oh, well if you still want to attempt the old movement system this script might work (the decimal in the multiplication block controls the speed) Completely misread your post, sorry, this code below won't work in your case.

whenclickedforeverifkeyspacepressed?thenchangexbymousex-xposition*0.1changeybymousey-yposition*0.1

However, if you don't mind changing the direction of your sprite, you could probably do this for the sprite to move at a consistent speed:

whenclickedforeverifkeyspacepressed?thenpointindirectionmouse pointermove...steps

Last edited by AwezomeXD (Nov. 12, 2021 16:23:55)

Powered by DjangoBB