Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Gliding object collision detection
- dak-jr
-
3 posts
Gliding object collision detection
Testing a shooting game.
Have a sprite that move around using glide but if it's hit by the “bullet” sprite, it explodes. Works flawlessly if the glide block is not in place but of course, it's not moving either.
It also seems to work randomly. I sit there and “pull the trigger” several times and it all of a sudden will explode the target. Sometimes it takes 20 trigger pulls, sometimes 50, etc… The bullet sprite seems to be hitting the target every time as the script calls for the bullet sprite to disappear on contact and it does but no explosion…
Bullet sprite:
-when i receive
go to
point towards
play sound
show
repeat until
touching or touching
Have a sprite that move around using glide but if it's hit by the “bullet” sprite, it explodes. Works flawlessly if the glide block is not in place but of course, it's not moving either.
It also seems to work randomly. I sit there and “pull the trigger” several times and it all of a sudden will explode the target. Sometimes it takes 20 trigger pulls, sometimes 50, etc… The bullet sprite seems to be hitting the target every time as the script calls for the bullet sprite to disappear on contact and it does but no explosion…
Bullet sprite:
-when i receive
go to
point towards
play sound
show
repeat until
touching or touching
- dak-jr
-
3 posts
Gliding object collision detection
Sorry, hit submit before I did the whole post…
Testing a shooting game.
Have a sprite that move around using glide but if it's hit by the “bullet” sprite, it explodes. Works flawlessly if the glide block is not in place but of course, it's not moving either.
It also seems to work randomly. I sit there and “pull the trigger” several times and it all of a sudden will explode the target. Sometimes it takes 20 trigger pulls, sometimes 50, etc… The bullet sprite seems to be hitting the target every time as the script calls for the bullet sprite to disappear on contact and it does but no explosion…
Bullet sprite:
>when i receive
go to
point towards
play sound
show
repeat until (touching or touching )
move steps
hide
Target sprite:
>when flag clicked
forever loop
if (not touching then
glide to x y
else
switch costume
play sound
wait
hide
wait
switch costume
show
I have it hide and show just to reset the target sprite for testing. Again, if I remove the glide, works perfectly but I want a moving target so that's no good.
Any help is appreciate. New to this so sorry if it's a dumb question.
Thanks
Testing a shooting game.
Have a sprite that move around using glide but if it's hit by the “bullet” sprite, it explodes. Works flawlessly if the glide block is not in place but of course, it's not moving either.
It also seems to work randomly. I sit there and “pull the trigger” several times and it all of a sudden will explode the target. Sometimes it takes 20 trigger pulls, sometimes 50, etc… The bullet sprite seems to be hitting the target every time as the script calls for the bullet sprite to disappear on contact and it does but no explosion…
Bullet sprite:
>when i receive
go to
point towards
play sound
show
repeat until (touching or touching )
move steps
hide
Target sprite:
>when flag clicked
forever loop
if (not touching then
glide to x y
else
switch costume
play sound
wait
hide
wait
switch costume
show
I have it hide and show just to reset the target sprite for testing. Again, if I remove the glide, works perfectly but I want a moving target so that's no good.
Any help is appreciate. New to this so sorry if it's a dumb question.
Thanks
- drmcw
-
1000+ posts
Gliding object collision detection
Gliding pauses the script until it is complete so any other blocks in that script won't be running. If you have touching blocks then you need to run them at the same time the glide is happening so need to split the script into parallel ones; one to move and one to sense.
Last edited by drmcw (Feb. 25, 2014 19:24:09)
- dak-jr
-
3 posts
Gliding object collision detection
Thanks drmcw, worked perfectly.
Thanks for the quick response.
Thanks for the quick response.
- wspwll
-
1 post
Gliding object collision detection
Would you mind showing an example? I'm really struggling to making the parallel script work
Thank you!

- asivi
-
1000+ posts
Gliding object collision detection
Please don't revive old topics, your response doesn't make sense since the original post is almost three years old. Would you mind showing an example? I'm really struggling to making the parallel script workThank you!
Last edited by asivi (Dec. 26, 2016 17:15:30)
- Discussion Forums
- » Help with Scripts
-
» Gliding object collision detection