Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Some more updates over the past few days! Here's where I'm at now:

  • I added some more exaggeration to the star animations on the HUD. I don't want them to be too distracting, but they are kinda small and I think they needed to be a little more noticeable than they were before.
  • I've added animation to the little door icon in the HUD. It now flips over to reveal an "open door" icon when you've collected the 5 stars necessary to open the door.
  • There's now an in-game button prompt for when you're nearby objects in the game that the player can interact with
  • I started adding sound effects. Currently sounds are hooked up to jumping, running, landing, and collecting stars.
  • I added a pause screen. Currently you can pause, resume, and quit the game. There is no main menu yet, so "Quit to Main Menu" currently does nothing.

For the most part, adding sound effects was pretty straightforward and didn't give me too much trouble. The only issue I had was in implementing the footsteps, so I wanted to go over the problem I encountered and the solution I ended up finding. It is probably not the best solution (in terms of cleanliness and efficiency), but at the end of the day it gave me the results I wanted. I thought documenting it might help someone who had a similar issue - or, at the very least, it'd be nice to come back to this for my own reference.

So... logically, I knew what I needed to do. I made a few footstep sounds, and I wanted to hook them up in such a way that...

  • you only hear the footsteps when the character is running
  • the footstep sound only played during the part in the animation where one of her feet hit the ground
  • the footstep sounds were randomized - I had made three sound effects, and I wanted the game to play one of them at random each time the sound was needed

I did a bit of googling and found out you can make what's called a "cue" in Blueprints, which would allow me to randomize the sounds:

So every time I played the cue, one of the three footstep sounds was chosen at random. Sweet! Then it came time to hook it up to the player character, and this is where I ran into trouble:


As I'd mentioned in an earlier post, I made an animation state machine that would check what state the player was in and then play the correct flipbook corresponding with that state. So to hook up the footsteps, I pulled from the output of the Animation State Machine to check and see which flipbook was currently active. Next, I used a branch to check if the running flipbook was the current one. If it is, I check to see which frame the animation is currently on. The characters feet touch ground at frame 5 and frame 11, so I used another branch to check and see if one of those frames is the current frame. If it is, I want to play the footstep sound cue.

But after all this was hooked up, I didn't get the result I wanted:

The footsteps sounded totally fine in the editor when playing the sound cue, but in game there was this strange distortion that sounded like a loud buzz playing overtop the sound effect. I tried a few things that helped me rule out some obvious issues, then finally, by hooking up the jump sound effect to the run animation, I was able to get a clearer idea of what was going wrong: the sound effect was being triggered multiple times in rapid succession, which was causing a sort of reverb effect. But why?

I had forgotten something essential about the way the game engine works. The time unit for the game engine is ticks, whereas animations are broken into frames. Frames are not the same as ticks, and ticks occur much more frequently than frames. In order to check what state the character was in, I was checking it each tick. Then, if it was discovered that the run animation was active, and that the current frame was a foot contact frame, the sound was triggered. But the problem was that this loop was happening every tick, and because multiple ticks occur in the time space of a frame, the sound was being triggered multiple times in a row. This meant I needed to set up my node graph a bit differently:


So, again, there's probably a more elegant solution to this, but here's what I came up with. I created a boolean variable called "StepSoundPlayed," which I'm basically using as an on/off switch. I'm still running through the same series of checks - if the run animation cycle is currently playing, and what frame we're on if it is - but whenever it's time to play the footstep sound I'm now setting "StepSoundPlayed" to true. And at the beginning of the loop I'm checking "StepSoundPlayed." If it's true, it means the sound just played and I don't want to play it again, in which case I'm waiting until the frame before the next footstep (frame 4 or 10) and then resetting it (switching it to "false").

With the boolean switch in place, it worked great!

That's it for this update. More to come soon.