Discuss Scratch

TehEpicDuckeh
New Scratcher
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
Scratcher
1000+ posts

Collision not detecting?

I suggest using
touchingcolorenemy color?
over color touching color in the enemies.
baconlover5555
Scratcher
100+ posts

Collision not detecting?

yeah i dont think the “touching sprite” block works with clones of the sprite.
deck26
Scratcher
1000+ posts

Collision not detecting?

baconlover5555 wrote:

yeah i dont think the “touching sprite” block works with clones of the sprite.
@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.
DrGoat
Scratcher
7 posts

Collision not detecting?

The bullet or whatever.
whenIstartasacloneforeverwaituntiltouchingTarget?deletethisclone

The target

whenclickeddotargetthingsheremoveextwhenclickedforeverwaituntiltouchingBullet?sayOw (put health removal code here)
TehEpicDuckeh
New Scratcher
4 posts

Collision not detecting?

deck26 wrote:

baconlover5555 wrote:

yeah i dont think the “touching sprite” block works with clones of the sprite.
@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 tried that but it still doesn't work. link: https://scratch.mit.edu/projects/86410630/
deck26
Scratcher
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.
TehEpicDuckeh
New Scratcher
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
Scratcher
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
Scratcher
1000+ posts

Collision not detecting?

deck26 wrote:

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.
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.
TehEpicDuckeh
New Scratcher
4 posts

Collision not detecting?

Thanks a lot dude now it works! I am only starting so yeah thanks!
BKFighter
Scratcher
1000+ posts

Collision not detecting?

TehEpicDuckeh wrote:

Thanks a lot dude now it works! I am only starting so yeah thanks!
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.

Powered by DjangoBB