Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Smooth Rotation
- Oisthebestletter
-
100+ posts
Smooth Rotation
Hey! I was making a game and was sick of the regular “point towards” block that we have. I needed something smoother that lags a bit behind. So I watched this tutorial and put it in this project, but I got stuck on the part with the “funky animation” that the turret does. See for yourself! 

- Oisthebestletter
-
100+ posts
Smooth Rotation
No, if you go to the left side of the screen and put your mouse in the bottom of the screen, then go to the top, it makes it do a weird spin thing. It seems to be working fine.
- wavewavegame
-
26 posts
Smooth Rotation
That part was intentional in the code, I am unsure on how to prevent objects from flipping in scratch.
- Oisthebestletter
-
100+ posts
Smooth Rotation
DID YOU EVEN WATCH THE VIDEO- That part was intentional in the code, I am unsure on how to prevent objects from flipping in scratch.
- Oisthebestletter
-
100+ posts
Smooth Rotation
Sorry, i get fired up sometimesDID YOU EVEN WATCH THE VIDEO- That part was intentional in the code, I am unsure on how to prevent objects from flipping in scratch.

- Im_here_for_fun
-
10 posts
Smooth Rotation
though I don't know much about calculus, the problem could be the arctangent block, however I doubt it, because the problem isn't visible when the cursor is moved slowly. I don't think it's that there's something different between your project and the one in the tutorial, it's that the spaceship moves too slowly to make the turret spin in the opposite direction, while using the mouse allows for faster movements. I honestly have no idea how to fix it.
- Oisthebestletter
-
100+ posts
Smooth Rotation
Oh, ok. And by the way, it's trigonometry, not calculus though I don't know much about calculus, the problem could be the arctangent block, however I doubt it, because the problem isn't visible when the cursor is moved slowly. I don't think it's that there's something different between your project and the one in the tutorial, it's that the spaceship moves too slowly to make the turret spin in the opposite direction, while using the mouse allows for faster movements. I honestly have no idea how to fix it.

- TheCreatorOfUnTV
-
1000+ posts
Smooth Rotation
Deleted
Last edited by TheCreatorOfUnTV (Jan. 21, 2025 03:22:42)
- nembence
-
100+ posts
Smooth Rotation
The problem is that you can cross the north-south line in a way that there are no checks in the regions above and below the line. (eg. by moving almost horizontally near the turret or by moving very fast)
A more reliable way to check crossing the line is using the difference between targetAngle and lastAngle. If the difference is bigger than 180 degrees, then the target crossed the line.
This works because for every two positions there are two angles between them that add up to 360°, so one of them is bigger and the other is smaller than 180°. The difference measures the angle that doesn't cross the line, so if it's bigger than 180° then the smaller angle is the one that crosses the line.
A more reliable way to check crossing the line is using the difference between targetAngle and lastAngle. If the difference is bigger than 180 degrees, then the target crossed the line.
This works because for every two positions there are two angles between them that add up to 360°, so one of them is bigger and the other is smaller than 180°. The difference measures the angle that doesn't cross the line, so if it's bigger than 180° then the smaller angle is the one that crosses the line.
- s714655
-
100+ posts
Smooth Rotation
https://scratch.mit.edu/projects/1123119011/ <– tried to fix it
- RokCoder
-
1000+ posts
Smooth Rotation
this tutorial and put it in this project, but I got stuck on the part with the “funky animation” that the turret does. See for yourself!This is a nice solution to your problem that allows you to also pass in the speed of rotation - Hey! I was making a game and was sick of the regular “point towards” block that we have. I needed something smoother that lags a bit behind. So I watched
- Oisthebestletter
-
100+ posts
Smooth Rotation
Thanks!this tutorial and put it in this project, but I got stuck on the part with the “funky animation” that the turret does. See for yourself!This is a nice solution to your problem that allows you to also pass in the speed of rotation - Hey! I was making a game and was sick of the regular “point towards” block that we have. I needed something smoother that lags a bit behind. So I watched
- Discussion Forums
- » Help with Scripts
-
» Smooth Rotation