How to make the Enemy Bomb destructible?

I’m trying to get the Player Laser to interact with the Enemy Bomb.

I tried adding the ‘Enemy’ script, but that didn’t work. Is it the Layer that needs to be adjusted?

Hi,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime?

1 Like

This is what I have so far:

Dubugs for the collision, the damage dealer, and the destruction.

There is no collision between Player Laser and Enemy Bomb.

Debug log shows collision only when the bomb interacts with the Shredder at the bottom.

Red errors are because I plunked an enemy in the scene when it wants to be part of a spawn path.

Have you already used layers and the layer collision matrix? If so, maybe the laser is on a layer which does not interact with the player.

Or both the laser and the player have got trigger colliders.

1 Like

Collision boxes here: I’ve messed with checking and unchecking boxes, still not getting collision between Player Laser and Enemy Bomb (Enemy Projectile).

Still no luck with making the Enemy Bomb destructible as an Enemy Projectile. I messed with a lot of the settings in the layer collision matrix.

I changed the Enemy Bomb from the Layer: Enemy Projectile to Layer: Enemy and the bomb is now destructible.

I still don’t understand why it wasn’t working as an Enemy Projectile.

Full Fix:

  • Added new Script based on Script:Enemy to the Enemy Bomb
  • Deleted the programming in Script:Enemy telling the bomb to shoot, shoot sounds, etc.
  • Changed the Enemy Bomb from Layer:Enemy Projectile to Layer:Enemy
  • Adjusted Layer Collision Matrix: No Check on; EnemyProjectile-EnemyProjectile, Enemy-EnemyProjectile, Player-PlayerProjectile, Player-Player

Good job on fixing the issue, and thanks for sharing your solution. :slight_smile:

One last thing you could check: In your last screenshot, I can see that the Body Type of the Rigidbody2D component is set to “Kinematic”. Take a look at the collision action matrix at the bottom of this webpage:

Maybe both “colliding” colliders were kinematic. That would explain why certain collisions didn’t work.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms