Sound and Light Experiments

Read Time:2 Minute, 51 Second

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.

The Back Feet method is triggered by the animation event.

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.


Lighting

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:

But soft what light is the there in this scene?
There is none because the Skybox isn’t working.
Because I made all the things static.

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.

This is better.

Pickups

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…

Found it!

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.


Bug List

  1. The colliders are not falling down with the bodies.
  2. The zombie is picking up health (but on purpose for testing).

Features List

  1. Ammo and Ammo pickups.
  2. Pickups disappear for a short time and then respawn.
  3. The Mechanic carries a weapon and has her own attack, hit, and death animations.

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *