Adding A Zombie To Our Game

Would be cool to see a screenshot if you’ve made any improvements to what I added…

My first try:

I don’t like the “hit” animation, but it is what it is… :disappointed_relieved:
I have add a Serialized Time off when the enemy is hit.

5 Likes

Hello!
I added four hit events to the attack animation, so each zombie hand hits twice per animation (they do less damage). I like the fight-or-flight response I feel as the enemy hits many, many times in a short period of time (especially in melee combat in FP-style games). Kind of more frantic or in a panic, like “Ahh I’ve got to get away from this thing!” I feel like it fits well. :smiley:

4hits

3 Likes

Hey Rick and everyone here, just little note on the ending of the video code. In my case I found another bug that when zombie die it said SetDestination blablabla, well inside the update I just set this code:

if (health.IsDead())
        {
            enabled = false;
            navMeshAgent.enabled = false;
            GetComponent<CapsuleCollider>().enabled = false;
            return;
        }

I disabled the capsule collider of the zombie (so I not being trapped from them when dead forever) and add the return otherwise the other IF statement that check if zombie is provoked being executed :slight_smile:
This will not fix the fact that the zombie if you shoot multiple time not stay dead, that’s fixed in the EnemyHealth adding the other control to the if health <0 like so for prevent multiple call of Die()

if (hitPoint <= 0 && !isDead)

Hope that will be helpfull for people here.

Another things that puzzle me is that as show in the image, why if I little turn down weapon the body look like dismembered, only when dead ???

4 Likes

Added a run, attack, and death animation since my last share. Hope you enjoy!

2 Likes

Is been a while since i did an update because i could not figure out the animations with my Assets Pack.
Finally i found a video on how to use the Synty Models with mixamo (https://www.mixamo.com/#/) to add animations. :smiley:
Still a way to go, especially the gun is bad. But the results i like for now. (to atleast continue)

Animator is a hell because i cant seem to set the loop animations (animations from mixamo seem to be read only(. So i fixed that by creating double states with exit times so it repeats constantly. :nerd_face:

1 Like

i turned off components < EnemyAI >, < NavMeshAgents > in < Enemyhealth > component itself using GetComponent , i am really impressed with my improvement. i can now understand whole script and modify scripts without breaking anything… and kind’a feeling sad course’s about to add.
thanks ben, rick and the team! :sweat_smile:

1 Like

Found a bug in this lesson, not sure if it’s addressed in a later video.
I’ve found in both my project and Rick’s project that I downloaded that at a certain distance (quite close), the zombie animation continues to walk toward you but doesn’t attack. Must be some blind spot in the code/parameters. Any ideas? See GIF below about 15 seconds in.
zombie bug (1)
@Rick_Davidson

1 Like

Help! I have provoked some serious guys…

Hey, thanks! I was running into the same SetDestination error with my NavMesh, and your code fixed it.

I owe you a beer.

Cheers!

1 Like

I’ll pay it forward here by sharing something I learned fixing a bug:

I implemented Patrizio’s fix and my enemy bodies had their capsule colliders turned off after the Death animation, but my weapons still had their box colliders on so I was bumping into them, but not the bodies. Awkward!

So I implemented this fix:

        if (health.IsDead())
        {
            this.enabled = false;
            navMeshAgent.enabled = false;
            var colliders = GetComponentsInChildren<Collider>();
            foreach (var collider in colliders)
            {
                collider.enabled = false;
            }
            return;
        }

This targets both the capsule collider on the Enemy, and the box collider on the weapon (that is, if you have one on there.) and turns them both off when the enemy is dead so you don’t trip on any guns :slight_smile:

I hope this helps!

Thanks for the fix.

I am having trouble. The damage isn’t changing the health bar for the zombie when shot by the player, and the player’s health doesn’t go down when hit by the zombie.

I had to change the enemy cause the original enemy, I put it in one and not a parent.

I solved it! It was the capsule collider veering off to the bottom

Privacy & Terms