Discuss Scratch
- Discussion Forums
- » Suggestions
- » a [point towards x( ) y( ) block
- gdfsgdfsgdfg
-
Scratcher
1000+ posts
a [point towards x( ) y( ) block
my post got deleted so I will say this instead
please stop saying “use a sprite/clone” as a workaround
the trig function is more reliable than the sprite one
please stop saying “use a sprite/clone” as a workaround
the trig function is more reliable than the sprite one
- scratchy_boy106
-
Scratcher
1000+ posts
a [point towards x( ) y( ) block
my post got deleted so I will say this insteadWhat is a trig function
please stop saying “use a sprite/clone” as a workaround
the trig function is more reliable than the sprite one
- TimothyLawyer
-
Scratcher
1000+ posts
a [point towards x( ) y( ) block
trig is short for trigonometry, a math subject about triangles and measurement
a trig function takes an input value (e.g., an angle) and gives an output value (e.g., a side length divided by another side length) from a triangle
in scratch the trig functions are
and their inverses with “a” in front of the name
more explanation can be found here
an example of a trigonometric function used to do point towards can be found here
atan is the inverse of tan, so instead of taking an angle and giving a ratio of side lengths, atan takes a ratio of side lengths and gives an angle
atan doesn't give the correct angle for all input values for doing points towards, so a second function called atan2 was created to do that
this project has both a “points towards x y” and “atan2 y x” custom block inside
a trig function takes an input value (e.g., an angle) and gives an output value (e.g., a side length divided by another side length) from a triangle
in scratch the trig functions are
([sin v] of ()::operators) // = opposite side / hypotenuse
([cos v] of ()::operators) // = adjacent side / hypotenuse
([tan v] of ()::operators) // = opposite side / adjacent side
and their inverses with “a” in front of the name
more explanation can be found here
an example of a trigonometric function used to do point towards can be found here
trigonometric “point towards”
This method uses the trigonometry function “atan” to calculate the direction between your current position and the target with math.define point towards x: (target x) y: (target y)
point in direction ([atan v] of (((target x) - (x position)) / ((target y) - (y position)))
if <(target y) < (y position)> then
turn cw (180) degrees
end
atan is the inverse of tan, so instead of taking an angle and giving a ratio of side lengths, atan takes a ratio of side lengths and gives an angle
atan doesn't give the correct angle for all input values for doing points towards, so a second function called atan2 was created to do that
this project has both a “points towards x y” and “atan2 y x” custom block inside
- supercroissants
-
New Scratcher
69 posts
a [point towards x( ) y( ) block
big math stuff about triangles and stuff, you learn about it in high schoolmy post got deleted so I will say this insteadWhat is a trig function
please stop saying “use a sprite/clone” as a workaround
the trig function is more reliable than the sprite one
why hasn't this been added yet? it's kinda hard to skip over a block as simple as this
- HAL95131
-
Scratcher
100+ posts
a [point towards x( ) y( ) block
big math stuff about triangles and stuff, you learn about it in high schoolmy post got deleted so I will say this insteadWhat is a trig function
please stop saying “use a sprite/clone” as a workaround
the trig function is more reliable than the sprite one
why hasn't this been added yet? it's kinda hard to skip over a block as simple as this
It also kind of feels like bad code practice to me to do a lot of trig every time you want to point to a certain spot on the screen..
- supercroissants
-
New Scratcher
69 posts
a [point towards x( ) y( ) block
also the fact that half the users on scratch don't even know what trig isbig math stuff about triangles and stuff, you learn about it in high schoolmy post got deleted so I will say this insteadWhat is a trig function
please stop saying “use a sprite/clone” as a workaround
the trig function is more reliable than the sprite one
why hasn't this been added yet? it's kinda hard to skip over a block as simple as this
It also kind of feels like bad code practice to me to do a lot of trig every time you want to point to a certain spot on the screen..
- TimothyLawyer
-
Scratcher
1000+ posts
a [point towards x( ) y( ) block
then this would be a good opportunity to learn, but also you don't need to know to use the workaround
here's the version from the project without the edge case fix, which should be good enough for most use cases
you only need to code it once and then can use it in any sprite in your project
for use in other projects add it to your backpack
here's the version from the project without the edge case fix, which should be good enough for most use cases
define point towards x: (x) y: (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))::operators) + ((180) * <(y) < (y position)>))
you only need to code it once and then can use it in any sprite in your project
for use in other projects add it to your backpack
- supercroissants
-
New Scratcher
69 posts
a [point towards x( ) y( ) block
then this would be a good opportunity to learn, but also you don't need to know to use the workaroundrequiring users as young as 9 to learn trig so they use an essential block like this is an awful idea
here's the version from the project without the edge case fix, which should be good enough for most use casesdefine point towards x: (x) y: (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))::operators) + ((180) * <(y) < (y position)>))
you only need to code it once and then can use it in any sprite in your project
for use in other projects add it to your backpack
Last edited by supercroissants (Sept. 11, 2026 02:46:41)
- supercroissants
-
New Scratcher
69 posts
a [point towards x( ) y( ) block
you should be able to understand it thoughhere's a way to do it with acosMany Scratchers are 8 to 12 years old, so I don't think this would be understandable.
that's the beauty of a custom block, you put it in your backpack, add it to your project, and don't have to understand what it is doing internally to use it in your project
that's the main idea of scratch, turning code into something you can understand
- Dom_206
-
Scratcher
85 posts
a [point towards x( ) y( ) block
you should be able to understand it thoughhere's a way to do it with acosMany Scratchers are 8 to 12 years old, so I don't think this would be understandable.
that's the beauty of a custom block, you put it in your backpack, add it to your project, and don't have to understand what it is doing internally to use it in your project
that's the main idea of scratch, turning code into something you can understand
tru
- Dom_206
-
Scratcher
85 posts
a [point towards x( ) y( ) block
Id also like to say that you should be able to understand a workaround Incase you want to modify it of make it do something else. And a lot of scratch's userbase is 8-13 so highschool math doesn't work if you want to understand the block.
- Discussion Forums
- » Suggestions
-
» a [point towards x( ) y( ) block