Random Tweaks and Additions
With the help of a friend, I was able to add a cool tweak to our Enemy AI. I initially wanted the AI to always spawn behind the player. This is because it would seem rather jarring to have the Enemy randomly pop into existence in front of the player. I have since implemented this feature.
If you remember our EQS query from last week, I have added a new Dot product test to it. This test takes the rotation of our player actor and scores EQS locations higher if they are behind the player.
Mesh Distance Fields
This is a very small change, but it can greatly improve performance. All I had to do was check a box and Unreal took care of the rest. Basically, Unreal will automatically create lower resolution versions of my 3D models and swap them in when they are far from the player.
Explaining how Mesh Distance Fields work is somewhat beyond the scope of this blog post, so you can check out the official documentation here to learn more.
The New Radio Tower Model
This week I created a new model for the radio tower. I might circle back to this model and look into creating an animation of the tower collapsing. You can checkout the livestream here.
Using Quixel Megascans
Quixel is a company that specializes in using photogrammetry to create hyper realistic 3D models. Quixel stores these models in a library they call Megascans. You can use their desktop software called Bridge to automatically download models and import them into your software of choice.
In November of 2019, Epic games (The creators of the Unreal Engine) purchased Quixel and made their services free to all users of the Unreal Engine.
I intend to use some models from the Megascans library to add some small details to the terrain here and there. For starters, I used these two models to create a lamppost.
Do You Hear Something?
The last major addition for this week is adding audible footsteps to our player. These footsteps will also change dynamically depending on the terrain type the player is walking on.
To get started, I collected various free sound effects online.
I then created two Sound Cue objects for grass and gravel. I technically have 4 different terrain types, but I will be using these two for now.
This is what the Audio Cues look like:
When the Audio Cue is played, it will select a random audio file and modulate the pitch and volume slightly. This allows for each footstep sound to be somewhat unique, despite using only four sound effects. I might experiment more with these sound effects in the future.
I also had to do some smaller tweaks in the background to setup the terrain detection. I had to create each surface type in the project settings under physics. I also created two Physics Materials that are assigned to the terrain itself.
Finally, I setup the blueprint logic on our player.
This logic basically starts a looping timer and changes the timer duration based off the player current velocity. To check which sound we need to play, we do a raycast at the player’s feet and do a switch statement on the terrain type. Again, for the time being, I am only using a grass and gravel sound effect.
Demo Time!
That’s all for this week. Thanks for reading!