Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » fastest way to find distance
- Jareddddddd
-
1000+ posts
fastest way to find distance
I need the fastest way to find the distance between to sprites, not using X and Y coords.
For reference, this is a raycaster, so it shoots rays out and records how long it takes to hit something. I would like the absolute fastest way you can do this
My current code (for finding distance)
For reference, this is a raycaster, so it shoots rays out and records how long it takes to hit something. I would like the absolute fastest way you can do this
My current code (for finding distance)
- crazyy_coder
-
8 posts
fastest way to find distance
here you are!
https://scratch.mit.edu/projects/617713863/editor/
https://scratch.mit.edu/projects/617713863/editor/
- Konserverad_gran
-
77 posts
fastest way to find distance
Also, if you haven't already done so, remember putting the code under a custom block and toggling “run without screen refresh” on. This makes it faster.
- Burnt-Butter-Toast
-
78 posts
fastest way to find distance
Well, you could use the Pythagorean Theorem, a^2 + b^2 = c^2. I need the fastest way to find the distance between two sprites, not using X and Y cords.
For reference, this is a raycaster, so it shoots rays out and records how long it takes to hit something. I would like the absolute fastest way you can do this
My current code (for finding distance)
Makes the slope into a right triangle where the vertical line is a leg (a or b) and the flat line is also a leg (also a or b)
Be sure the x
OK ignore ALL of that, while trying to find what I was trying to say I say a “distance to mouse pointer” but you can change it to a sprite and use that value
- Discussion Forums
- » Help with Scripts
-
» fastest way to find distance