How to make sprites point at eachother

I am making a game where you go around the map collecting presents and I am trying to make it where my character can point at the closest present or all of the presents in the array. But I have no idea how to do that so please help.

2 Likes

well you can do it by using the atan2 function.
first thing ill ask is
do you know about radians?

I can help… maybe. Can you share it with me?

I do not

ye https://arcade.makecode.com/S29907-04396-40117-67423

well here is my explanation
radians are like an angle in degrees but insted of 0° to 360° radians go from 0 to 2π
or 0 to 6.28318530718
now you might think that thats a weird amount. but that becuse that a radians is the point on a circle with a radius of 1
so a radiant is the distance traveled on its circumference
here is an example as images
image
image

since atan2() is a trig function it works with radians so to get the angle between two sprites you can do

Math.atan2(y1-y2,x1-x2)

and that outputs the angle in radians between two sprites
if you want more information on radiens you can watch this video
https://youtu.be/cgPYLJ-s5II (please note that i did not make this video)
but you can use the sprite util extension and the rotate image extension these two extension can help a lot

Thank you for your response it was very helpful.