Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make bullets go to the right enemy
- RealNames10
-
Scratcher
17 posts
How to make bullets go to the right enemy
I have a code like this:
set to (X)
set to (Y)
add to
add to
Then another one in a When I start as a clone that adds to a counter
Then in the Bullet Sprite I added this script:
There is another script that makes it point to a random direction and move but when I run it, the bullets appear at (0,0) and not where the enemy is.
set to (X)
set to (Y)
add to
add to
Then another one in a When I start as a clone that adds to a counter
Then in the Bullet Sprite I added this script:
go to x: (item (Counter) of [X] ) y: (item (Counter) of [Y] :: list)
There is another script that makes it point to a random direction and move but when I run it, the bullets appear at (0,0) and not where the enemy is.
Last edited by RealNames10 (June 11, 2021 23:30:27)
- Thingied
-
Scratcher
1000+ posts
How to make bullets go to the right enemy
I would suggest sharing the project instead of saying the code because not every script fits every project.
- RealNames10
-
Scratcher
17 posts
How to make bullets go to the right enemy
Here is the game:https://scratch.mit.edu/projects/473508548/
- Thingied
-
Scratcher
1000+ posts
How to make bullets go to the right enemy
Make a new global list called “shoot” and a new variable local variable in “sprite5” called “i” and do this:

(make the shoot function/custom block run without screen refresh)
Make another local variable called “ID” in “sprite4” and do this:


The clones change an item in “shoot” which tells “sprite5” to check to see which item got changed. If it finds the item that changed then it spawns a clone that goes to whatever item “i” is in the lists “X” and “Y”

(make the shoot function/custom block run without screen refresh)
Make another local variable called “ID” in “sprite4” and do this:


The clones change an item in “shoot” which tells “sprite5” to check to see which item got changed. If it finds the item that changed then it spawns a clone that goes to whatever item “i” is in the lists “X” and “Y”
Last edited by Thingied (June 12, 2021 00:00:02)
- RealNames10
-
Scratcher
17 posts
How to make bullets go to the right enemy
These changes has worked so well and I'm really happy to get a working answer!
- Discussion Forums
- » Help with Scripts
-
» How to make bullets go to the right enemy

