Тёмный

SYNC YOUR UNITY GAME TO THE BEAT 

b3agz
Подписаться 16 тыс.
Просмотров 17 тыс.
50% 1

Опубликовано:

 

22 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 62   
@Cyclone1024
@Cyclone1024 7 месяцев назад
I’m a hardware audio design engineer who designs PCM bus and audio serial interfaces for a living. I was scoffing at this at the beginning, but ended up stealing all the code
@b3agz
@b3agz 7 месяцев назад
I'm pinning this 😂
@pureay2700
@pureay2700 3 месяца назад
​@@b3agzIt's been 4 years since your videos first got me into really programming my own projects (my boxes engine) and I'm once again led back to you lmao
@prispalos
@prispalos 10 месяцев назад
This is **the definitive way** to handle beat matching in Unity. You can't even imagine how much you saved me with this video. Cheers!!
@b3agz
@b3agz 10 месяцев назад
Glad it helped!
@labyrinthHealth
@labyrinthHealth 2 месяца назад
I know 99% of people who see this can easily figure it out, but by adding a Slider control to the BeatController script, you can control this in game by setting the pitch of the audio source to the value of the Slider. Great tutorial!!!
@mi6ometala
@mi6ometala Год назад
I was trying to accomplish the same effect with Coroutines and WaitForSeconds(), but that wasn't perfect (it desynced every now and then). Your solution is much more elegant and useful! Thanks for the tips!!! PS: The steps thing is called note length. *2 would be a half note (2 notes per beat), *4 - a quarter note etc. And I guess 0.5 would be "half-time". (I'm not a very good musician, though. So take it with a grain of salt)
@trulyazul4162
@trulyazul4162 3 месяца назад
Thank you so much for this video! Trying to get audio to sink to a beat has been the bane of my existence across so many engines, and yet this works well and was surprisingly simple to follow!
@Joey-tb8fh
@Joey-tb8fh Год назад
This is genuinely brilliant. I've been working on my university project for some time and was getting frustrated with the game being out of sync with my music, especially given the song is fast paved so it's very obvious very quick. This couldn't have been shown to me at a better time!
@feli7487
@feli7487 Год назад
For as long as I can remember I've been curious about how I could synchronize enemy attacks with the music, and this is the most complete I've seen. Thank you very much :)
@Vintagestep
@Vintagestep 6 месяцев назад
I'm just starting my internship and I'm very new at Unity but I was told to learn it and research on topics I'd like to know. I'd like to work with music and audio, I do some music myself as well, so this was a good start. I did some changes, like setting an offset to the beats so they would align to the down beat for example, added a start delay for songs that are not made to loop. This was a very good starting point for someone that knows some programming and knows a little bit abut music.
@saing_rbn5368
@saing_rbn5368 Месяц назад
How did you manage the offset?
@Vintagestep
@Vintagestep Месяц назад
@@saing_rbn5368 Well, tbh the solution is not very elegant because it's proportionally inverse to how we understand beats, but I'll try to explain: what we want to modify is when the rhythm trigger/interval happens right? So in that class declare a float, I called mine " private float _phaseOffset = 0f;", you can add the [serializefield] to tweak it in the menus. Then since it's a fixed value, it will move the beat at a fixed rate when it's checked by doing "int currentPulse = Mathf.FloorToInt(pulse + _phaseOffset);" after that you do the check "if (currentPulse != _lastPulse) " and the operation to update the pulse and trigger it in the method "checkforNewInterval". The values of the offset have to be set between 0~1, more will just cycle over.
@seaweeddol8171
@seaweeddol8171 6 месяцев назад
Great video! I made a small rhythm game for a game jam where you have to interact on the beat, but it wasn't synced properly. This tutorial helped me get it working better.
@b3agz
@b3agz 6 месяцев назад
Awesome! Glad it helped.
@marionateixido1789
@marionateixido1789 5 месяцев назад
Hi! can you share or explain how you coded the part of interacting on the beat? I'm trying to do the same for a game and I'm having some problems
@letenebrae3164
@letenebrae3164 Год назад
Hifi-rush got me really curius on how music syncing works and this tutorial helped me a lot 😄
@kylopootis6489
@kylopootis6489 Год назад
i was so stuck using fixedUpdate, altering timesteps, time.time multiplied by blah blah, using different ways but the game kept getting out of sync after a few minutes. thank you so much
@I-OMusic
@I-OMusic 3 месяца назад
Bro explained the math so well I went straight in and built it first try
@keviin0
@keviin0 6 месяцев назад
I don't know if anyone mentioned it but a good name for the _steps variable would be _subdivisions I think. As musicians, we subdivide a beat in our head to help us visualize rhythms which is essentially what you're doing with transforming something like a whole note into half notes, quarter notes, eighth notes, etc.
@dustydudle880
@dustydudle880 Год назад
Finally! An advertisement that's something I'm actually interested in, and it doesnt even ask me to go to a website for answers!
@wolfeygamedev1688
@wolfeygamedev1688 Год назад
super cool! I added a scriptableobject that contains the audioclip and the BPM to be able to switch songs and have the BPM for it.
@leomassafm160
@leomassafm160 Год назад
Mind sharing the code/script? I'm making a rhythm game myself and would really like something that can switch tempo on the fly without manually inserting it
@wolfeygamedev1688
@wolfeygamedev1688 Год назад
@@leomassafm160 well you still have to manually insert the bpm as a field of the SO
@leomassafm160
@leomassafm160 Год назад
@@wolfeygamedev1688 does the scriptableobject also take into account mid-song tempo changes? Rock songs have a lotta fluctuations in tempo...
@owencoopersfx
@owencoopersfx Год назад
I’m working on an all-around sound and music management system for Unity native audio, and was not sure how to accurately track beats to assist with more precise music transitions. I think this is a great way to get me started. Thanks!
@overjuiced
@overjuiced Год назад
Fantastic tutorial. Glad I decided to consult RU-vid. It was a little hard to follow at the pace of the video but after going back and forth a few times I got it. Thanks so much!
@b3agz
@b3agz Год назад
The music used in the video is piece by Johnnie Holiday kindly released as a CC0 track ( freesound.org/people/Johnnie_Holiday/sounds/563651/ ) and the asset pack used is Unity's own free 3D Game Kit ( assetstore.unity.com/packages/templates/tutorials/3d-game-kit-115747?aid=1101l9Tam& )
@brockproosdy8066
@brockproosdy8066 Год назад
absolutely brilliant video, very underrated. Saved my ass more than once
@gabrielwhite9881
@gabrielwhite9881 Год назад
Thats so great. What a cool idea to write a script for that issue to figure out how to do things on beats. :) pls more of that kind of small helpful scripts that solving one issue.
@b3agz
@b3agz Год назад
Thanks! If you have things you'd like me to tackle let me know. Can't promise I'm smart enough to solve it but I love trying to figure things like this out.
@enchantgames_
@enchantgames_ Год назад
this was perfect! You are an angel!
@_NEWN_
@_NEWN_ 7 месяцев назад
Very helpful. Thank you bro!
@CarlitoxBanana
@CarlitoxBanana 3 месяца назад
Best video so far!!!
@JohnnieHoliday
@JohnnieHoliday Год назад
Nice! Thanks for support!
@b3agz
@b3agz Год назад
Thank you for making a great tune :D
@sneakysunset1765
@sneakysunset1765 2 месяца назад
I saw this video some time ago that would actually fix some problem I had with my game. But unfortunatly I'm using FMOD and the game is porting to android. I tried a lot but honestly I think i'm going back to built in and using this I'm fed up with FMOD.
@cimaaaaaaa
@cimaaaaaaa 23 дня назад
love it
@random32i8
@random32i8 Год назад
one thing i've found doesnt work with this well is having a song with a dynamic bpm because it makes the interval variable just randomly move around
@Demisemæn
@Demisemæn Год назад
bro, why you dont use the fft blackman harris formula from unity?
@Kiru176
@Kiru176 Год назад
For some reason I still have an issue with syncing. Also the bpm doesn't seem to do anything for some reason?
@nefelibata263
@nefelibata263 10 месяцев назад
if my BPM increases linearly, will changing the corresponding BPM variable inside my game at the same time work with this code?
@b3agz
@b3agz 10 месяцев назад
It should. As long as your BPM variable correct for track at any given moment, it will always be in sync with the music, even if the BPM changes. You just need to make sure your BPM variable is always right.
@nefelibata263
@nefelibata263 10 месяцев назад
@@b3agz hmm, I see. I have an incremental game with a background beat that increases linearly from 80bpm to 160bpm in 92 seconds (numbers are not exact). I can't figure out a way to make it completely sync to the whole thing, since the gameplay itself consists of a ball going back and forth, at a certain speed that increases every x seconds. I kind of came back to hardcoding certain speeds, since I couldn't find a way to change the speed according to the increasing BPM down to floating point precision, but your tutorial was still really informative. the problem is that it cannot be synced at really fast speeds since it desyncs so easily and I can't find the exact 15+ decimal points number for acceleration to keep it consistent with the beat. thanks for the reply!
@_NEWN_
@_NEWN_ 7 месяцев назад
I had a question if you don't mind. How would I make it so that if you press a certain button on one of the beats per minute, something happens?
@b3agz
@b3agz 7 месяцев назад
If I'm understanding you right, you should be able to use the UnityEvents system to trigger a "beat" and then just check if the beat is currently triggered.
@candenizgumus5308
@candenizgumus5308 Год назад
art
@AlexGeek
@AlexGeek 11 дней назад
This reminds me of Pineapple on Pizza game.
@felixfontain6423
@felixfontain6423 Год назад
When comes the Showreveal of Jam3
@b3agz
@b3agz Год назад
Should be up towards the end of this coming week.
@davidharmon7467
@davidharmon7467 Год назад
Simples!
@RazeGames654
@RazeGames654 11 месяцев назад
Can it be used in 2D objects??
@b3agz
@b3agz 11 месяцев назад
Yes, you can use it with any game object. There's no fundamental difference between a 2d and a 3d object to unity.
@felixfontain6423
@felixfontain6423 Год назад
First
@uuhhhhhhhhhhhhhhhhhhhhhhhhhh
@uuhhhhhhhhhhhhhhhhhhhhhhhhhh 10 месяцев назад
Thank you, @b3agz! 🔊🔊🔊🔊🔊
@Sacroooooooooooooooooooooooooo
FOR PEOPLE WHO PUT IN THIS CODE BEFORE REALISING IT'S FOR BEATS, NOT PRE RECORDED TRACKS First of all, you need ```using System.Linq;``` This might take a while, but you can add ```[SerializeField] private float[] _skips;``` to the start of Intervals and then do ```if(!(_skips.Contains(_lastInterval))) { // _trigger.invoke, etc}```. Then you can put every note to skip if there is no beat there.
@Kiru176
@Kiru176 Год назад
I have a pre-made music with its beat being a core part. I now wanted to use it for a rhythm puzzle game. Can you explain this solution? Somehow my object is still out of sync with TestBeat() and the BPM variable doesn't seem to be affecting it for some reason. I'm still looking through it.
@Sacroooooooooooooooooooooooooo
@@Kiru176 I'll make a google doc. It might help.
@Sacroooooooooooooooooooooooooo
@@Kiru176 docs.google.com/document/d/1REb2SxXYiFDRq_n2ceY-ue_wvWAV-umKf64Xzk9BgYc/edit?usp=sharing
@Kiru176
@Kiru176 Год назад
@@Sacroooooooooooooooooooooooooo Thank you.
@victornogueira2992
@victornogueira2992 8 месяцев назад
@@Sacroooooooooooooooooooooooooodid you make it?
Далее
The Secret To Good Rhythm Games
15:50
Просмотров 149 тыс.
Making a RHYTHM Game in 2 Days!
5:55
Просмотров 150 тыс.
MAKE A MAZE IN UNITY
30:51
Просмотров 18 тыс.
I Made a 3D Game Engine Inside Another One
8:04
Просмотров 77 тыс.
Simple Physics Based Helicopter Controller in Unity
12:59
Dear Game Developers, Stop Messing This Up!
22:19
Просмотров 721 тыс.
The Power of Scriptable Objects as Middle-Men
17:41
Просмотров 127 тыс.
Say Goodbye to the Animator! NEW Unity Plugin Showcase
15:40
FMOD + Unity Beat Tracking
27:07
Просмотров 8 тыс.
LET IT SNOW - Super Simple Snow System for Unity
13:01