Can't shoot enemies from the back

Hi there,

I am unable to shoot and kill enemies from the back. This problem was solved in the following post: Question on the use of Bullet + OnTriggerEnter. But it’s not quite clear to me how. In my opinion it shouldn’t work because the bullets Collide and bounce of the Capsule collider when you shoot enemies from the back. It never reaches the BoxCollider and is Destroyed, same as when it hits the walls.

I grabbed the following image from the closed topic which describes the situation perfectly. With the Collidor setup we make in the lecture, it shouldn’t be possible to kill the enemies from the back.

I am obviously missing something regarding Triggers vs. Collisions and hoping to figure out what.

Thanks in advance!

Hi Roel,

The question is: In which collision event message does your code destroy the bullet?

If the CapsuleCollider2D is a non-trigger collider and the bullet hits that non-trigger collider, the OnCollision*2D method gets called (if there is any in your code). If there isn’t such a method or if that method does not destroy the bullet, the bullet bounces off the enemy’s non-trigger collider.

Is this what you wanted to know?

Hi Nina,

I looked through the lectures and see that in later lectures, Rick’s Goober enemy has a CapsuleCollider with “isTrigger” checked. When we first setup the enemy in Lecture 94 -Setup Your Enemy (https://www.udemy.com/course/unitycourse/learn/lecture/28740576#overview) “isTrigger” does not get checked. So I probably missed this step later on in the course somewhere.

Kind regards and thanks for the fast reply.
Roel

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

Privacy & Terms