Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » point to X Y
- nickwasp
-
100+ posts
point to X Y
Is there a script that will make a sprite point to an X Y position on the play field? If there is please help. Thanks!
- Spontaneous08
-
100+ posts
point to X Y
You could have a small, invisible sprite go to where you want it to point, and have it point to that sprite. Use this block.
If any further explanation is needed, tell me.
point towards [ spritex]
If any further explanation is needed, tell me.
Last edited by Spontaneous08 (April 19, 2016 00:22:28)
- asivi
-
1000+ posts
point to X Y
Hi nickwasp, yes it exists
https://scratch.mit.edu/projects/96662382
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
https://scratch.mit.edu/projects/96662382
- gor-dee
-
1000+ posts
point to X Y
point in direction (([atan v] of ((((x position) - (X)) / (((y position) - (Y))0))9)) v)
- nickwasp
-
100+ posts
point to X Y
Hi nickwasp, yes it existsdefine apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
https://scratch.mit.edu/projects/96662382
Thank you his is exactly what i needed! Could you tell me what atan meens and also maybe why you need the
((180) * <(y position) > (y::custom) >)
Last edited by nickwasp (April 19, 2016 15:43:45)
- BKFighter
-
1000+ posts
point to X Y
Yes.Hi nickwasp, yes it existsdefine apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
https://scratch.mit.edu/projects/96662382
Thank you his is exactly what i needed! Could you tell me what atan meens and also maybe why you need the((180) * <(y position) > (y::custom) >)
1) atan is just shorthand for inverse tangent
2) Normally thats used in an if statement to switch between two different equations but they have shortened it too one equation. That still returns true false, but here it is a 1 or 0, which can be used in the equation.
- asivi
-
1000+ posts
point to X Y
Hi, i'm going to share a link to a web where it is explained a lot of better i'm able to do it.
Inverse Sine, Cosine, Tangent

To see by yourself that script in your second question does i have added a variable “atan”
If you don't understand that, excuse me, it is my fault.
Greets.
Inverse Sine, Cosine, Tangent

To see by yourself that script in your second question does i have added a variable “atan”
define apuntar hacia (x) (y)this other
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
set [atan v] to ([atan v] of (((x) - (x position)) / ((y) - (y position))))
<(y position) > (y::custom)>maybe true or false, when true it adds 180 to the calculated atan in order to correct the quadrants for the direction.
If you don't understand that, excuse me, it is my fault.
Greets.
- CornW1
-
23 posts
point to X Y
Here's A Project I Made: https://scratch.mit.edu/projects/313328698/
Here Is The Code That the project uses:
PLEASE GIVE CREDIT!!!
Here Is The Code That the project uses:
when green flag clicked
forever
Point Towards (0) (0)
define Point Towards (X) (Y)
point in direction ( (((180) * <<(y position) > (Y)> or <((y position) + (90)) = (Y)>>) + ([atan v] of (((x position) - (X)) / ((y position) - (Y))))))
PLEASE GIVE CREDIT!!!
Last edited by CornW1 (Dec. 29, 2019 22:40:12)
- cchen-tcsyl
-
72 posts
point to X Y
here is a thing you can view the code in the project https://scratch.mit.edu/projects/396382957/
define
point torwards(x(y))
- balmerazTSC
-
26 posts
point to X Y
hmm…
I was thinking the same thing.
the script doesn't seem to be working, It there another way!?
I was thinking the same thing.
the script doesn't seem to be working, It there another way!?
when green flag clickedA block like this would be great:
wait until <(Omg i cant figure this out) = [true]>
go to [Forum v]
Hope that there is a way without trig to do this
point towards x: [ ] y: []
- Cutie_Pooge
-
500+ posts
point to X Y
Please make your own topic. For the answer, there is no way to calculate direction without trigonometry but scratch's hmm…
I was thinking the same thing.
the script doesn't seem to be working, It there another way!?when green flag clickedA block like this would be great:
wait until <(Omg i cant figure this out) = [true]>
go to [Forum v]
Hope that there is a way without trig to do thispoint towards x: [ ] y: []
point towards [ v]block does it for you. If you want you can make some global variables containing positions of where you want to look, broadcast a message to tell another sprite to go there and then use that block.
- IguanaLover
-
100+ posts
point to X Y
Hi nickwasp, yes it existsdefine apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
https://scratch.mit.edu/projects/96662382
Sweet, this worked perfectly!
- deck26
-
1000+ posts
point to X Y
No need to necropost to say that though.Hi nickwasp, yes it existsdefine apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
https://scratch.mit.edu/projects/96662382
Sweet, this worked perfectly!
- OrbiterYT
-
100+ posts
point to X Y
Not really, not without a script(((((???)))))Is there a way to do it without trig?
- HedwigsHat
-
1000+ posts
point to X Y
when green flag clicked
forever
go to x: (pick random (-272) to (272)) y: (pick random (-214) to (215))
point in direction (x position)
wait (pick random (1) to (10)) secs
point in direction (y position)
- hunterfabby
-
24 posts
point to X Y
this worked thank you Hi nickwasp, yes it existsdefine apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
https://scratch.mit.edu/projects/96662382
- ScratchCat1038
-
1000+ posts
point to X Y
Make 2 sprites, one should be invisible. Also, make 2 variables, x and y.
Type this in the first sprite:
Type this in your 2nd sprite:
Type this in the first sprite:
when green flag clicked
point towards x: (some number) y: (some number) :: custom
define point towards x: (x) y: (y)
set [x v] to (x)
set [y v] to (y)
broadcast [some broadcast v] and wait
point towards [your 2nd sprite v]
Type this in your 2nd sprite:
when I receive [some broadcast v]
go to x: (x) y: (y)
- 27182818284590
-
70 posts
point to X Y
It worked thank you Hi nickwasp, yes it existsdefine apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
https://scratch.mit.edu/projects/96662382
- Discussion Forums
- » Help with Scripts
-
» point to X Y