Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » "point towards" block math
- H2OtastesGood
-
Scratcher
8 posts
"point towards" block math
What are the mathematics behind the “point towards” block? I'm assuming this doesn't only apply to Scratch
I am currently trying to find a work around to calculating how fast a sprite is spinning when it goes near 180 and -180 degrees:
https://scratch.mit.edu/projects/992047744/
I am currently trying to find a work around to calculating how fast a sprite is spinning when it goes near 180 and -180 degrees:
https://scratch.mit.edu/projects/992047744/
- mybearworld
-
Scratcher
1000+ posts
"point towards" block math
The main code's here, where the important part is:
// util.target is the current sprite, targetX and targetY represent the x and y coordinates to point towards const dx = targetX - util.target.x; const dy = targetY - util.target.y; const direction = 90 - MathUtil.radToDeg(Math.atan2(dy, dx));
- Discussion Forums
- » Advanced Topics
-
» "point towards" block math