Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Mouse-pointer rotation shenanigans
- Whitepatchwastaken
-
100+ posts
Mouse-pointer rotation shenanigans
How do I make a sprite rotate towards my mouse pointer at a set speed, kinda like a Dartling Gunner from Bloons TD? Thanks in advance! ![](//cdn.scratch.mit.edu/scratchr2/static/__e900675e2487039095475b713d9e2612__/djangobb_forum/img/smilies/big_smile.png)
![](http://cdn.scratch.mit.edu/scratchr2/static/__e900675e2487039095475b713d9e2612__/djangobb_forum/img/smilies/big_smile.png)
the small text ruse was a…….. DISTACTION⠀⠀⠀⠀⠀⠀i HAVE the kumquat
Whitepatch!
Did you mean: griffpatch
sometimes Putting effort into my posts since 2022
I program games and then never share them
I crawl around Help with Scripts when I feel like giving/getting help
Whitepatch!
Did you mean: griffpatch
sometimes Putting effort into my posts since 2022
I program games and then never share them
I crawl around Help with Scripts when I feel like giving/getting help
- Spentine
-
1000+ posts
Mouse-pointer rotation shenanigans
Ok… so… are you familiar with trigonometry…? Because you're going to have to find the vector of the relative positions and move it like that…
- JimboJones47
-
100+ posts
Mouse-pointer rotation shenanigans
Here is one way. You could look at how this was done. This has a block that runs without screen refresh. It sets one variable to the current direction the sprite is facing, then rotates to the direction of the mouse pointer and gets that direction. Finally, it rotates back to the direction it was before. Since this is done without refresh you won't see the sprite jerk back and forth.
Once it has those 2 angles, it takes the difference, and figures out if it should rotate left or right. Finally, it limits the amount of rotation by the rotation speed variable, and turns.
https://scratch.mit.edu/projects/639482566/
Once it has those 2 angles, it takes the difference, and figures out if it should rotate left or right. Finally, it limits the amount of rotation by the rotation speed variable, and turns.
https://scratch.mit.edu/projects/639482566/
- deck26
-
1000+ posts
Mouse-pointer rotation shenanigans
https://scratch.mit.edu/projects/55006278 might help
- Whitepatchwastaken
-
100+ posts
Mouse-pointer rotation shenanigans
This helps a lot, thanks for the help! Here is one way. You could look at how this was done. This has a block that runs without screen refresh. It sets one variable to the current direction the sprite is facing, then rotates to the direction of the mouse pointer and gets that direction. Finally, it rotates back to the direction it was before. Since this is done without refresh you won't see the sprite jerk back and forth.
Once it has those 2 angles, it takes the difference, and figures out if it should rotate left or right. Finally, it limits the amount of rotation by the rotation speed variable, and turns.
https://scratch.mit.edu/projects/639482566/
![](http://cdn.scratch.mit.edu/scratchr2/static/__e900675e2487039095475b713d9e2612__/djangobb_forum/img/smilies/smile.png)
the small text ruse was a…….. DISTACTION⠀⠀⠀⠀⠀⠀i HAVE the kumquat
Whitepatch!
Did you mean: griffpatch
sometimes Putting effort into my posts since 2022
I program games and then never share them
I crawl around Help with Scripts when I feel like giving/getting help
Whitepatch!
Did you mean: griffpatch
sometimes Putting effort into my posts since 2022
I program games and then never share them
I crawl around Help with Scripts when I feel like giving/getting help
- Discussion Forums
- » Help with Scripts
-
» Mouse-pointer rotation shenanigans