(Redirected from Go to ())
- "Go to" redirects here. For the block that makes a sprite go to a specific coordinate, see Go to X: () Y: () (block).
- This article is about Motion Blocks. For Scratch 3.0's Looks Block, see Go to () Layer (block).
|Go to ()|
go to ( v)
The go to () block is a motion block and a stack block. The block sets its sprite's X and Y position to the specified position, which can be that of another sprite, the mouse pointer, or random coordinates.
Unlike the go to x: () y: () block, which moves a sprite to the specified coordinates, the go to () block moves a sprite to a specified location.
Some common uses for the go to () block:
forever go to (mouse-pointer v) end
- A piece of clothing that must stay with the sprite that wears it
forever go to (person v) end
- Preventing a sprite from moving
forever go to (Sprite1 v) end
- Controlling a pencil with the mouse
forever if <mouse down?> then go to (mouse-pointer v) pen down else pen up end end
- Changing the position of objects on a hidden treasure game
when green flag clicked go to (random position v)
If the block is used in a forever loop to make a sprite go to a moving sprite, the former will appear to lag behind the latter. This can be fixed by instead using the following script:
when green flag clicked // in moving sprite forever ... broadcast (message1 v) and wait end when I receive [message1 v] // in other sprite go to (moving sprite v)
- Main article: List of Block Workarounds
With the sprite going to the mouse-pointer:
go to x: (mouse x) y: (mouse y)
With the sprite going to another sprite:
go to x: ([x position v] of (wanted sprite v)) y: ([y position v] of (wanted sprite v))
With the sprite going to a random position:
go to x: (pick random (-240) to (240)) y: (pick random (-180) to (180))