Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make sprite check another sprite's costume?
- Tryggered85
-
Scratcher
1 post
How to make sprite check another sprite's costume?
In my game, the player is able to shoot projectiles which defeat enemies. When the projectile hits an enemy, it briefly explodes as a visual effect before the clone deletes. My problem is that I ca not figure out how to make the projectile only affect enemies when it is one sprite. My current setup is:
All that is in the enemy code, the projectile code simply does a cool animation before deleting itself. Any tips on how to make the enemy register the projectile's costume so it only counts before it explodes? Thanks.
when I start as a clone(hopefully that pictures right)
forever
if <touching [ v] ?> then
end
end
All that is in the enemy code, the projectile code simply does a cool animation before deleting itself. Any tips on how to make the enemy register the projectile's costume so it only counts before it explodes? Thanks.
- RoboticUnicorn000
-
Scratcher
41 posts
How to make sprite check another sprite's costume?
In my game, the player is able to shoot projectiles which defeat enemies. When the projectile hits an enemy, it briefly explodes as a visual effect before the clone deletes. My problem is that I ca not figure out how to make the projectile only affect enemies when it is one sprite. My current setup is:when I start as a clone(hopefully that pictures right)
forever
if <touching [ v] ?> then
end
end
All that is in the enemy code, the projectile code simply does a cool animation before deleting itself. Any tips on how to make the enemy register the projectile's costume so it only counts before it explodes? Thanks.
You can get the costume number/name for another sprite with this block:
([ costume] of [Sprite1 v])You can find it in the Sensing category. Let me know if that works or if you need any more help!
- dem_bot
-
Scratcher
1000+ posts
How to make sprite check another sprite's costume?
The simplest option would be to make the bullet add it's coords to two lists (x and y) and just delete itself and then have a particle fx sprite detect something is in the list, make a clone at that location and delete the list items and have that clone do the explosion animation.
A probably better option is if you keep track of where each enemy is at and use pythagoras' theorem or just checking if the coords are in range to detect a collision, in which case it doesn't matter what the bullet looks like and you will then also know which bullet hit which enemy, which is useful if you have different weapons.
A probably better option is if you keep track of where each enemy is at and use pythagoras' theorem or just checking if the coords are in range to detect a collision, in which case it doesn't matter what the bullet looks like and you will then also know which bullet hit which enemy, which is useful if you have different weapons.
- Discussion Forums
- » Help with Scripts
-
» How to make sprite check another sprite's costume?