(Redirected from Article of the Month)

Not to be confused with Point in Direction () (block).
 Point Towards () `point towards ( v)` Category Motion Type Stack

The Point Towards () block is a Motion block and a stack block that points its sprite towards the mouse-pointer or the costume center of another sprite.

## Example Uses

Unlike the Point in Direction () block, which does not point sprites at specific objects, the Point Towards () block can point sprites at other sprites or the mouse pointer.

Some common uses for the Point Towards () block:

• Continuously making a sprite point towards the mouse
```when gf clicked
forever
point towards (mouse-pointer v)
move (10) steps
```
• Guiding a sprite on where to move
```point towards (Sprite2 v)
repeat until <touching (Sprite2 v)?>
move (5) steps
```
• Pointing towards a goal in the project
```when I receive [Hint v]
point towards (Treasure v)
```

## Workaround

Main article: List of Block Workarounds

This block can be replicated with the following blocks, which uses trigonometry:

```set [delta_x v] to (([x position v] of (sprite 1 v)) - (x position))
set [delta_y v] to (([y position v] of (sprite 1 v)) - (y position))
if <(delta_y) = [0]> then
if <(delta_x) < [0]> then
point in direction (-90)
else
point in direction (90)
end
else
if <(delta_y) < [0]> then
point in direction ((180) + ([atan v] of ((delta_x) / (delta_y))))
else
point in direction ([atan v] of ((delta_x) / (delta_y)))
end
end

point in direction (([atan v] of ((([x position v] of (Sprite1 v)) - (x position)) / (([y position v] of (Sprite1 v)) - (y position)))) + ((180) * <([y position v] of (Sprite1 v)) < (y position)>)
```

However, this requires more code and decreases its readability.

## Related Suggestion

A related block for pointing a sprite at a specific coordinate has been often requested by Scratchers:[1] `point towards x: (0) y: (0)::motion`

This can be done by placing a sprite at that location and using the Point Towards () block, or by defining and using this custom block:

```point towards x:() y:() :: custom
define point towards x:(x) y:(y)
set [delta_x v] to ((x) - (x position))
set [delta_y v] to ((y) - (y position))
if <(delta_y) = [0]> then
if <(delta_x) < [0]> then
point in direction (-90)
else
point in direction (90)
end
else
if <(delta_y) < [0]> then
point in direction ((180) + ([atan v] of ((delta_x) / (delta_y))))
else
point in direction ([atan v] of ((delta_x) / (delta_y)))
end
end
```

A copy of this code may be obtained here.