Player and Enemies Not Getting Destroyed

Hello,

I am coming across an issue in my “Galaxy Ranger” game where even though I put the code to destroy the enemy to my Player.cs script, my player NOR my enemies are getting destroyed; the lasers are just passing through them. I even put some of my colliders to “Is Trigger”. What am I missing?

Hi Bilal,

In which course and lecture are you?

Laser Defender, Lecture 106 - “Player Life and Death”

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? Make sure the method names are spelt correctly.

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

Colliders can collide with colliders only. The enemies, the player and all lasers need Collider2D components attached. All moving game objects with colliders should have a Rigidbody2D component.

I put in the RigidBody2D components for the moving objects and the code is written exactly as it is in the lecture.

What about the colliders and the Debug.Logs?

This topic was automatically closed after 18 days. New replies are no longer allowed.

Privacy & Terms