Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » bullets
- richardnichols
-
23 posts
bullets
hi, how can i make a bullet hit the wall and both the bullet and the wall disappears? like a sprite fires a gun and the bullet comes out and hits the wall so both the bullet and the wall disappears.
- richardnichols
-
23 posts
bullets
yes but if i use it only one of them disappears and i want both to disappear.
- AonymousGuy
-
1000+ posts
bullets
Oh that is because of scratch execution times and stuff and how Flash Player is line-by-line blah blah blah… yes but if i use it only one of them disappears and i want both to disappear.
Anyways to fix it do this:
- AonymousGuy
-
1000+ posts
bullets
You're welcome! oh thats very helpful. thank you very much!

- JsnPrkr
-
100+ posts
bullets
Does each sprite check if it's touching the other sprite?
Depending on the timing of each sprite's script, if the bullet knows it hit the wall, it can hide itself and the wall can do the same. However, if the bullet hides and THEN the wall tries to check if it's touching the bullet, the Touching event never happens for the wall.
Which one disappears in your project?
Depending on the timing of each sprite's script, if the bullet knows it hit the wall, it can hide itself and the wall can do the same. However, if the bullet hides and THEN the wall tries to check if it's touching the bullet, the Touching event never happens for the wall.
Which one disappears in your project?
Last edited by JsnPrkr (Jan. 4, 2014 06:22:36)
- AonymousGuy
-
1000+ posts
bullets
Well the reason for the glitch is the scratch player can only execute one block at a time, so you have to make the sprite wait to allow the other sprite to realize its there. If you hide the sprite then the other one can't detect that it is there when the scratch executor comes to its detection script. Does each sprite check if it's touching the other sprite?
Depending on the timing of each sprite's script, if the bullet knows it hit the wall, it can hide itself and the wall can do the same. However, if the bullet hides and THEN the wall tries to check if it's touching the bullet, the Touching event never happens for the wall.
Which one disappears in your project?
- JsnPrkr
-
100+ posts
bullets
If you hide the sprite then the other one can't detect that it is there when the scratch executor comes to its detection script.
Is that not what I said?
Depending on the timing of each sprite's script, if the bullet knows it hit the wall, it can hide itself and the wall can do the same. However, if the bullet hides and THEN the wall tries to check if it's touching the bullet, the Touching event never happens for the wall.
When helping someone, it's good to find out what they've tried so they can learn from their efforts. There's more than one way to create the described behavior. Also better to teach someone to fish than hand them one, yes?
Last edited by JsnPrkr (Jan. 4, 2014 06:35:03)
- Discussion Forums
- » Help with Scripts
-
» bullets