Game
Rhythm, Paper, Scissors
7 years ago

Feeling wwiser with Callbacks


Gooooooooodmorning Vietna… Gamejolt! Or maybe it isn’t such a good morning when I think about it. Yesterday’s beautiful snow has turned into the sad state in between snow and water that we Swedes call “slask” and struggles are real here with Wwise+Unity. Anyway, Sebastian here. I’m gonna spend some time talking about the part that music is playing in this game and how we’re setting it up.

Wwise connection

As you might remember from my previous post, “Rhythm, Paper, Scissors” is heavily dependent on Unity knowing the Beats Per Minute (BPM) of the current song playing. With no experience of Wwise going into this project and limited programming skills I’ve expected this task to be quite difficult. But luckily there’s plenty of tutorials and documentation of all things Wwise, Unity and C#.

The goal is to send information from Wwise at every single beat of the current song and once at the start of every bar. With that given information my idea was to calculate the time passing between the beats, divide 60 with the time between beats and then get the BPM as a result. From there my intention was to let Unity anticipate when every new beat is supposed to hit and make the player perform varyingly strong attacks depending on how close to the beat you press any attack button.

The first part went pretty smooth. I set up a Wwise-project and imported an old song I’ve composed in ¾, 90BPM. The track was then connected to an event, sent to my soundbank and generated into my Unity-project.

5d0a94c95ec2a.png

All of this was fine. I wrote a simple script to send messages to me in the Debug Log at the start of every bar and every beat. I added an AkAmbient-component and started sending callbacks from here to a randomly chosen Game Object (in this case an object called “swing effect”). Into the swing object I added a C# script with two new functions with the exact names that the callbacks are sending the callbacks into (CallbackBeat and CallbackBar).

5d0a94ca05532.png

Below you can see what the Debug Log was showing me. I felt alive, as I thought that I would really start rolling from here.

5d0a94caa13dc.png

As you can see, this fits perfectly with the 3/4 time signature that the track is being played in! 3 beats, then we enter a new bar. However, things weren’t as simple when I wanted Unity to figure out the BPM of the song. As we know from earlier in this post, the track is being played in 90BPM. I added some calculations to the script to find out how much time that passes between each CallbackBeat. This was done by

I then stumbled upon a rather unfortunate find. The time passing seemed to be changing every beat.

5d0a94cb673f2.png
5d0a94cbeeb6d.png

What does this mean?

At this point in time I’m not entirely sure if my math is poor, my programming is poor or that Wwise actually doesn’t send callbacks 100% accurately according to a beat. I’m going to investigate this further to see what’s up.

I tried getting the “fBeatDuration”, information that Wwise is supposed to send to Unity, but couldn’t find a way to get it. After some good amount of Google I have learned that it’s likely that this feature isn’t compatible with Unity & C#.

I’m still learning new things about Wwise and how it works in Unity as I go. Being able to figure out the BPM is nice, but we want more. More importantly we NEED the BPM.

If we’re not able to find out how to get that information from Wwise we’ll have to find some other way to get this done. I have some ideas in mind but we’ll see what happens.

Stay tuned if you want to know what I’ve found out by the time of my next devblog.

Until next time,
Sebastian



0 comments

Loading...

Next up

Short intro of us 💕✌️

We're an eletro duo based in Seoul 🇰🇷 Heavily influenced by the 90s.

Our new album #Xennials is all about the nostalgia of that era 💽 CD listenin 📟 beeper beepin 💾 floppy disks floppin days 😎

Stream now! 🎧

https://open.spotify.com/album/3YwWhnHWVy5cA8XOpbaGRA?si=8E9awqU…

Fan art for Foolish I'm feeling kinda better so I drew this

Terraria

Shuiro Haname. #Commission

Commission for @ShuHaname

Only true badasses may pass! #conceptart #art #gamedesign

blender animation experimentation, getting the hang of things fast. arms, rig, & gun models by me ofc

Pigs can push buttons for you!

#gamedev #pixelart #screenshotsaturday

Don't forget to wishlist Toodee and Topdee on Steam!

https://store.steampowered.com/app/1303950/Toodee_and_Topdee/

What Are You Doing In My Swamp!?

Now spruce forest monsters can vomit forest shields, but Brutal Castle will not stop!

#gamedev #pixelart #indie

Pixel art gif