Discuss Scratch

DylanChilcoat
New Scratcher
3 posts

Clones Shooting and Dying Simultaneously

https://scratch.mit.edu/projects/125392600/#player

Hi, this is my first time coding a game in Scratch and my partner and I are running into an issue that we can't solve; our enemy1 sprite can only be deleted if there is no wait between each projectile it creates. Essentially, when it creates a bullet it takes several touches of the player's projectile sprite before it is deleted. Whereas if there is no wait between each shot from the enemy, a player's projectile instantly deletes it.

This is difficult to explain, and would be a lot more simple for someone to understand if they looked at the code (more specifically, the enemy1 sprite in the code). Any help would be greatly appreciated!
drmcw
Scratcher
1000+ posts

Clones Shooting and Dying Simultaneously

At the moment if it's a clone then once in position it shoots every half a second but cannot be killed. Without the wait block a forever loop will run each iteration 30 times per second. Presumably you want to still shoot every half a second but still delete the clone if I gets shot? if so one way would be to replace he wait with

repeat15iftouchingbullet?thendeletethisclone

because 15 iterations of a loop will take half a second.
eh6239qr
Scratcher
100+ posts

Clones Shooting and Dying Simultaneously

You could try adding a Wait .1 Seconds block before the Delete Clone block. Like this:

iftouchingenemy1?thenwait.1secsdeletethisclone

Note that this will make the bananas visibly stop when they hit your enemy before disappearing.
DylanChilcoat
New Scratcher
3 posts

Clones Shooting and Dying Simultaneously

Hey thanks for the help guys, but my issue is still persisting. drmcw, your method doesn't appear to work for me as when I have it check if there it is touching the enemy and its costume is set to bullet, nothing happens. I'm not sure if maybe I'm implementing it wrong or it's not ordered correctly. eh6239qr, I don't think I explained my problem correctly. It is related to the projectiles shot from the enemy1, not the player projectiles interacting with the enemy1 sprite. Sorry I wasn't very clear.

eh6239qr
Scratcher
100+ posts

Clones Shooting and Dying Simultaneously

I just checked the project and it looks like you got it fixed. Anything else you need help with?
DylanChilcoat
New Scratcher
3 posts

Clones Shooting and Dying Simultaneously

I was playing with the code earlier, and yes while it shoots a stream of projectiles with no wait, enemies can be deleted. However, with the 0.5 second wait between enemy's projectiles added in (as it is now), the issue still persists where the enemy cannot be deleted.
drmcw
Scratcher
1000+ posts

Clones Shooting and Dying Simultaneously

DylanChilcoat wrote:

Hey thanks for the help guys, but my issue is still persisting. drmcw, your method doesn't appear to work for me as when I have it check if there it is touching the enemy and its costume is set to bullet, nothing happens. I'm not sure if maybe I'm implementing it wrong or it's not ordered correctly. eh6239qr, I don't think I explained my problem correctly. It is related to the projectiles shot from the enemy1, not the player projectiles interacting with the enemy1 sprite. Sorry I wasn't very clear.


I meant to replace the wait 0.5 inside the forever loop when it's a clone not a bullet. Isn't the problem that the clone cannot be shot?
NguyenDinhVu123
Scratcher
7 posts

Clones Shooting and Dying Simultaneously

im asking to do if all clones are cleared
whenclickedcreatecloneof myselfforeverifallclonesdiedthenbroadcastall clones died

Last edited by NguyenDinhVu123 (May 22, 2022 06:39:28)

Harakou
Scratcher
1000+ posts

Clones Shooting and Dying Simultaneously

Hi! This topic is rather old - when you ask for help on an old thread, people often will only respond to the original post because they don't notice yours. if you need help, you're much better off creating a new thread. Be sure to explain the problem you're having! If you have a question about a post that was made here, you can always include a link to it in your new topic. Thanks!

Powered by DjangoBB