Sync Audio Beat to Player Action

I need to figure out how to sync the beat of song to a player action. Eg: Having the player jump up at particular beats that has the player earn points when they hit the object on beat.

Animate function? Would appreciate some guidance…

I don’t know if Unity 3.0’s “Audio Magic” is going to make this any easier to deal with, but I hope so. This has been pretty high up on the list for awhile, so hopefully it has been addressed. You can vote it up for now, though, if you like.

For the time being, you’ll have to come up with your own way of defining where your beats are. What you actually need to store will vary based on the gameplay. Unity doesn’t have the ability to trigger sounds with good rhythm yet, but it can do a decent job with triggering visuals, considering we “see a lot more slowly than we hear”. What I recommend is storing the “beats” in a struct or class (struct is probably better but I’m not an expert on this), including at least two vital pieces of information: a float for their time, within the audio file, and a bool for whether or not they have been triggered.

So after you have an array of that beat struct/class, Increment a timer every frame that you aren’t paused. If the time is within a certain range of the beat (say 1/30th of a second or so), then run whatever function you want to. If the timer is greater than the “beat + range”, then that means the frame rate was too slow to catch the beat, so call the function at that point. In either case, mark the beat as having been triggered so the function doesn’t get called multiple times.

It’s really the definition of the timing of the beats that makes this a pain. For the moment, Unity doesn’t have a concept of musical timing. You can’t just ask Unity if somebody hit a button near an eighth note or something. As long as your audio file has a constant bpm, you could potentially make something fun. However, doing anything like the big rhythm games, such as Dance Dance Revolution, Guitar Hero, or Rock Band, that have you hit notes that aren’t just every whole/half/quarter/eighth note, but rather, reflect something interesting that’s happening in the song, is not likely something you’d want to take on in Unity yet, without a plugin.

Do you know of any mac games that are available such as Guitar Hero Aerosmith? I want to know if there are kid friendly music games (commercial is fine) for young ones to create their own music with.

any ideas on how this can be done yet ?

this post says its possible:
http://forum.unity3d.com/threads/33447-Are-rhythm-games-supposed-to-be-possible-or-not?highlight=audio+sync