Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » bullets
- richardnichols
- New to Scratch
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.
- JsnPrkr
- Scratcher
100+ posts
bullets
Do you know about these commands?
<touching [ v]?>
hide
Budding Scratchologist
Game: Pogo The Penguin
Gadgets: Drop-Down Menu, FlexibleSlider Control, Flexible Keyboard at UI Control Studio
Studio: The Dynamic A.I. Studio (Submit your A.I. project for inclusion!)
PLEASE CONSIDER… Handing out a quick solution on the first pass is a VERY EFFECTIVE way to sabotage a learning opportunity. Telling someone “it's easy” is a good way, too.
- richardnichols
- New to Scratch
23 posts
bullets
yes but if i use it only one of them disappears and i want both to disappear.
- AonymousGuy
- Scratcher
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:
when gf clicked //Put this script in bullet
show
forever
if <touching [wall v]> then
wait (0.1) secs //To allow wall to recognize it
hide
end
end
when gf clicked //Put this script in wall
show
forever
if <touching [bullet v]> then
wait (0.1) secs //To allow bullet to recognize it
hide
end
end
- AonymousGuy
- Scratcher
1000+ posts
bullets
You're welcome! oh thats very helpful. thank you very much!
- JsnPrkr
- Scratcher
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)
Budding Scratchologist
Game: Pogo The Penguin
Gadgets: Drop-Down Menu, FlexibleSlider Control, Flexible Keyboard at UI Control Studio
Studio: The Dynamic A.I. Studio (Submit your A.I. project for inclusion!)
PLEASE CONSIDER… Handing out a quick solution on the first pass is a VERY EFFECTIVE way to sabotage a learning opportunity. Telling someone “it's easy” is a good way, too.
- AonymousGuy
- Scratcher
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
- Scratcher
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)
Budding Scratchologist
Game: Pogo The Penguin
Gadgets: Drop-Down Menu, FlexibleSlider Control, Flexible Keyboard at UI Control Studio
Studio: The Dynamic A.I. Studio (Submit your A.I. project for inclusion!)
PLEASE CONSIDER… Handing out a quick solution on the first pass is a VERY EFFECTIVE way to sabotage a learning opportunity. Telling someone “it's easy” is a good way, too.
- Discussion Forums
- » Help with Scripts
- » bullets