Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Collision not detecting?
- TehEpicDuckeh
-
4 posts
Collision not detecting?
I am making a defence game but when my bullets hit the enemies they just pass through them? I have tried using touching color? and sprite touch sprite but I think it has to do with the bullets and most enemies being clones….
- BKFighter
-
1000+ posts
Collision not detecting?
I suggest using
over color touching color in the enemies.
- baconlover5555
-
100+ posts
Collision not detecting?
yeah i dont think the “touching sprite” block works with clones of the sprite.
- deck26
-
1000+ posts
Collision not detecting?
@BKFighter was suggesting you put the correct colour for the sprite (or clone) in that block. It should work. Share the project if it doesn't work as it's difficult to help otherwise. yeah i dont think the “touching sprite” block works with clones of the sprite.
- TehEpicDuckeh
-
4 posts
Collision not detecting?
@BKFighter was suggesting you put the correct colour for the sprite (or clone) in that block. It should work. Share the project if it doesn't work as it's difficult to help otherwise. yeah i dont think the “touching sprite” block works with clones of the sprite.
Yeah I tried that but it still doesn't work. link: https://scratch.mit.edu/projects/86410630/
- deck26
-
1000+ posts
Collision not detecting?
You have the script checking for touching only running when the broadcast is made. It needs to be in a forever loop.
I'd change the colour of the bullet and get the enemies to detect being touched by that colour. Also don't use the enemy sprite, just use clones of it.
I'd change the colour of the bullet and get the enemies to detect being touched by that colour. Also don't use the enemy sprite, just use clones of it.
- TehEpicDuckeh
-
4 posts
Collision not detecting?
Thanks, now the enemies aren't deleting but the bullets are i also tried using color but it did not work. Thanks for the assistance?
- deck26
-
1000+ posts
Collision not detecting?
You're deleting the bullet when it touches the sprite/clone but before the clone has chance to detect that it has been touched. So add a short wait in the bullet's script that detects the touch so the sprite/clone has chance to react.
- BKFighter
-
1000+ posts
Collision not detecting?
And I would recommend to make sure that the enemy has its bullet detection in another forever loop to make sure it doesn't have to wait through a long calculation, etc. before it detects the target. You're deleting the bullet when it touches the sprite/clone but before the clone has chance to detect that it has been touched. So add a short wait in the bullet's script that detects the touch so the sprite/clone has chance to react.
- TehEpicDuckeh
-
4 posts
Collision not detecting?
Thanks a lot dude now it works! I am only starting so yeah thanks! 

- BKFighter
-
1000+ posts
Collision not detecting?
It's fine. One way to learn these things is to look at the code of Scratchers who are moderatly better at you (it shouldn't be to easy, because then you don't learn anything) or too hard. Thanks a lot dude now it works! I am only starting so yeah thanks!
- Discussion Forums
- » Help with Scripts
-
» Collision not detecting?