I decided to try something different for the foot step sounds. For the gunshots you’ll recall that I used a dynamic ring buffer that instantiated prefabs of the sounds that were disabled after a time. This time I’ve placed all of the audio sources under the Dragon to start with. I still use a ring buffer.
For the Dragon’s attack roar I use the Audio Source on the Dragon Bite FX to play a one shot when the Attack Target component triggers the Attack Started event.
On the lighting front, I discovered that one of my problems arose when I marked all the Game Objects that were not Enemies or the Player as static to generate the Nav Mesh. This was too much. Turns out that there are many ways for objects to be static in Unity and being static in regards to lighting created the issues I was having. Namely this one:
I have a Game Object called world where all the buildings and things are organized. I had the setting on “Everything” because I just hit the checkbox. This was incorrect, it should just be Navigation Static for now. I’ll worry about the rest later.
The goal here is to get the Player to be able to pick up Health and Ammo. Of course, I haven’t added Ammo yet so I should do that too. Pro tip: a thing needs a Rigidbody to trigger a collision. I’m fairly certain I recall Rick and Ben presenting a nifty graph about this…
Since the Pickup uses a Static Trigger Collider, only a Rigidbody Trigger collider will pick it up. I slapped one on the Zombie for testing and I can confirm that both the Player and the Zombie received healing when running over the Health Pickup.
All collectible objects will use Pickup to detect the collision and will then invoke a Pickup Event to pass the Target on to a specialized component, like Health Bonus, via the event.
When Pickup detects a collision, it looks up the hierarchy of the colliding object for a Target. If it finds one the it invokes the Pickup Event on the Target.
In the case of a Health Bonus Pickup, the Target is checked for a Health component and, if one is found, the target is healed by a set amoung.
I did need to refactor the Health component a bit, realizing that I do not need both a Damaged By and Damage Taken event. What I really needed was a Health Changed event, so I changed the Damage Taken to Health Changed so that it can be invoked to trigger health updates to the GUI.
As a bonus, the HUD health update calls can be eliminated from places like the Spawn since they are handled by the Health Changed event which will be triggered by the call to Full Health.
- The colliders are not falling down with the bodies.
- The zombie is picking up health (but on purpose for testing).
- Ammo and Ammo pickups.
- Pickups disappear for a short time and then respawn.
- The Mechanic carries a weapon and has her own attack, hit, and death animations.