Discuss Scratch

Dolanred
Scratcher
6 posts

Issues with clone deletion

(operating system: Windows NT 10.0, Firefox 88.0)
I'm having some issues with clones not being deleted as they need to be.
The character fires shots from a gun, and the shots are supposed to be deleted on contact with an enemy. Instead, the enemy clone is deleted but the bullet keeps moving. I don't understand why it's doing this, because the shots are deleted on contact with edges as well, and that part works fine. I have no idea if this is just a bug, or if it's something I did in the coding, but it's frustrating and I can't seem to find a solution.
Here's what the script looks like. (Hope the Scratch blocks work, it's my first time using them.)
when I start as a clone
show
go to [ sprite 1]
point towards [ mouse]
repeat until <touching edge or touching zombie>
move (3) steps
end
delete this clone
BarelySmooth
Scratcher
1000+ posts

Issues with clone deletion

If possible could you post the link to the project so that I can experiment with it and check if anything is wrong. Thanks

Banner credit: @Prime689








(This text below is my forum signature)

Scratch Team never wrote:

Good suggestion. Let’s add that.
no offense to ST btw – Credit to @Fun_Cupcake_i81 for the above portion of the signature

Also, Nobody supports the support convention



404. That's an error.

The requested signature was not found under this post.
That's all we want you to know.
Dolanred
Scratcher
6 posts

Issues with clone deletion

Chiroyce
Scratcher
1000+ posts

Issues with clone deletion

Aha! I think this is because the zombies are deleted first, so the clones never touch the zombies as the script in the zombie sprite runs first.
this should fix it!

when I receive [delete enemy v]
wait (0) secs
delete this clone

Last edited by Chiroyce (June 2, 2021 15:48:26)








April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
Light_Shock
Scratcher
13 posts

Issues with clone deletion

when I start as a clone
go to [ sprite1]
point towards [mouse-pointer]
repeat until <<touching [edge] ?> or <touching [enemy] ?>>
move (3) steps
if <<touching [edge] ?> or <touching [enemy] ?>> then
broadcast [delete enemy]
delete this clone
end

end

when I receive [delete enemy]
wait (0.1) secs
delete this clone

AND that's the solution!

(The delete enemy script is put in the enemy sprite)
Light_Shock
Scratcher
13 posts

Issues with clone deletion

2nd POST!
Light_Shock
Scratcher
13 posts

Issues with clone deletion

Oops didn't relize Chiroyce already posted it, but whatever.

Powered by DjangoBB