The damage has been done

In this lecture we added damage to our projectiles. I’m still pretty excited that we have finally implemented the functionality that eluded us first time round in this course - with both the the player and enemies we can can easily switch between melee and projectile weapons.

1 Like

I’ve got something odd going on with my enemy that’s got a bow equipped. For some reason he doesn’t lay down when he dies. He does the animation and then just stands there. There’s also an issue where the enemies seem to die after one arrow is shot, rather than 2. each enemy has 20 HP and the bow does 10 damage. Took a look through the GitHub repository and couldn’t find anything in the scripts that’s different. I’m rather thorough when it comes to following along, but I can’t see what I missed. I can post a video, screenshots, or the whole game if needed. Just let me know.

Solved it. forgot to delete this line: target.TakeDamage(currentWeapon.GetDamage());
and had the bow attack overriding the death instead of the sword attack… guess that’s what happens when you do things at 3 AM. :grin:

1 Like

Can I ask you, what is wrong with my code?

Add the following line before the return statement in GetIsInRange()
if(!target) return false;

1 Like

I replaced the target with currentWeapon and now it works. But thank You for your help otherwise I would not find it.
if (!currentWeapon) return false;

1 Like

Ah, glad it was sorted. It’s actually generally a good idea to protect all reference calls.

1 Like