I just finished the combat polishing lesson of the Unity 3rd Person Combat & Traversal course. All this time I only had 1 enemy on the screen so I did not notice, but now that I got more than 1, I noticed that they are able to hit and kill one another. So my thinking was that I’d add a layer ‘Enemy’ and put both of them on that layer, and then in project settings make sure they cannot collide. But that is probably not the only thing I should be doing. How do I fix that? Thank you.
That’s actually the perfect fix. Well done.
They’re still hitting each other though. So what am I doing wrong…?
The enemies got a Enemy tag and Enemy layer on their base layer where their collider etc is too. And in project settings I unticked the collision between Enemy and Enemy. But they’re still hitting each other and able to kill one another.
Isn’t it because of this:
if(other.TryGetComponent<Health>(out Health health)) // if the other object has the health component then do this
Since the enemy also has the health component… ?
Should I create a separate health component for the enemy perhaps?
The WeaponDamage component also needs to be Enemy, as that’s what’s colliding with the other enemy in an attack.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.