It's super interesting to see how Udon can be so complex but, at the same time, so easy to understand one someone knows how explain it. Amazing job as always!
Glad you think so! This was a much longer video than my previous vids, with much more going on, so breaking it down enough so that it didn't become overwhelming was a bit of a focus for it. Glad it worked out ^^
The beauty of the UA-cam player is that I can change the playback speed when I want to see and hear things in the detail without telling the content creator to slow down.
Hi, I'm always watching videos and I'm learning a lot thanks to you guys. Can you tell me the udon gimmick that makes a sound when the player enters the space?
@@annlice418 glad to hear your learning alot. Hope your having fun with it ^^ it's all about the event node that triggers the code to run. Have a look at my 4th (?) latest video all about events, as it should help show how to make different bits of code run at different times ^^
Pretty sure you just use the node "audiosource, set Mute" (believe that's the name..) instead of "audiosource, pause". You could even make it a toggle by grabbing the current value (audiosource, get mute) and putting that through a "boolean, unary negation" node to flip the bool, and then set that as the bool value for the 'audiosource, set Mute' node. (the other method would be to just change the volume to 0 (audiosource, set volume) ; proved you're not changing it anywhere else) Hope that helps ^^
im adding a sound to an asset in my world that i want people to be able to pick up and toggle the sound on and off but i want it to default off how would i do that? I followed this tutorial but it always plays as soon as i load in the world
Haven't use the node before, but looking at the documentation (and sorry I haven't tested it) it should work just like my 'how to play audio button' tutorial (ua-cam.com/video/cQ3hWKY-NiA/v-deo.html). You will however need to tell it what clip to play (I would just use either a public audioClip variable or an 'audioSource, get clip' node), and you can also hit the dropdown to adjust the volume too. Hope that helps ^^
you would simply replace the 'event, interact' node with an 'event, onPlayerTriggerEnter' --> 'playerApi, isLocal' --> 'branch' -(true)-> As seen in my Jumpscare tutorial. Hope that helps ^^
I'm trying to make a music box for my world so I was wondering if there was a way to make it where once you click the music box both the music will play, the handle will move, and once you click it again, it stops.
this weirdly doesnt work for me anymore... i dont know why. i booted up unity after a while and i did a map build and test, but i simply cant hear the sound... whatever i tried...
Check to see that the udon component hasn't forgotten it's values. Other than that, I'm not sure without asking a lot more questions. I would recommend asking on the official vrchat discord, where you can add photos to greatly help the debug process
Thank you again! It seems that when the audiosource is not on a loop, and the audio ends, the button no longer works. I think the logic is flipping the bool somehow. If I catch the clip and stop it before it ends, I can play it again, but if it plays it self out, the button stops working. Any Advice?
@@PlayerBush001 Thank you for responding! I should have followed the rest of the tutorial more. I ended up with exactly what you had in the end, I just had to do it the hard way. :D I usually have odd needs for my worlds that most of the tutorials work for but I end up having to tweak slightly, When I watched the first part, I was like, oh that is mostly what I need, Ill run with that. But it ended up working out. I am really grateful for your tutorials! I am working with another one, right now, the respawn changer. I run a VRC talk show, and wanted an eject button that would send the guest to another room, It took about 4-5 hours but learned that you cannot teleport a player, or respawn them when they are sitting. At least I havent figured out a way. So I ended up creating a script that teleports the chair and replaces it with a new chair, and does a bit of ring around the rosey. My Udon is not the cleanest but I am pretty proud of it. Would love to show it to you if you are interested.
You wouldn't be the first to not watch all the way through XD As for why exactly it was crashing; when the audioSource went to change the clip, it was probably doesn't like the 'audioSource, stop' node. If it wasn't playing, the script likely crashed as it couldn't stop the audioSource. Glad you were able to come up with a decent solution on your own though, as that's better learning than any tutorial you could follow ^^ As for your chair problem, that is an interesting one. Now, unfortunately you can only teleport the local player. You need to instead tell the other player that they need to teleport, and get them to teleport themselves. However, there isn't any good way to tell a particular player to play some code. But, on the 'udonBehaviour, send custom networked event' node, it has the option to either tell everyone (all) to play the custom event, or just the owner of the object. So what you can do, is that when someone walks or enters a seat in your world, you can use the node 'networking, set owner' to make them the owner of the object. Then, when you need them to teleport, you can use the 'udonBehaviour, send custom networked event' node to tell them, the owner, to teleport outda there. However, there are other methods too. If they are in a immobile station (aka, a chair), then you can move the 'exit' object to where you want them to leave, and then get them to leave the station and they will exit where the 'exit' object is. Another method (if you haven't got them in a seat/station) is to activate a small trigger collider object right where the player's area is. Then, using 'onPlayerTriggerEnter', get it to teleport the playerapi. that would avoid needing to even keep track of who is there (just hope no other contestants enter the zone also. Then again, you could play a funny animation of something falling on them or something, to make it a funny fail instead). But hey, that's just how I would do it. whatever works works. Just have fun with it ^^
@@PlayerBush001 The 'onPlayerTriggerEnter" box over the player is exactly what I had in place! I had two bits of code running there, one to spawn the box in and the other on the box to get them to teleport out. I would test it, and it would work fine, but then when they would sit in the chair, (in the same spot), they would stay put. It was driving me bonkers until I figured out that chairs were tricky that way, not a lot of info on that. Plenty of info on how to set up a basic chair, but thats about it. I guess no one is trying to do cheeky stuff with chairs, or if they do dont make tutorials on it :D I remember seeing a comment or a bit in one of your videos about telling the player to tell themselves to teleport themselves, but I wasnt really sure where to start. I did see the customer networked event node with the tell everyone, but I hadnt thought to make them the owner, brilliant! Ill mess around with that in the next rev. I thought about changing the exit point for the chair, but I read that VRC doesnt like when the exit point is too far away from the start, so I didnt bother. Teleporting the chair seems to give me the behavior that I am looking for, I just swap out Chair one for chair two, and bobs your uncle, player disappears and a new seat is there. Then the ejected player can take their time to leave said chair and rejoin the group. Then if I need to eject another, chair two gets moved, and chair one is back in the beginning with some toggle logic. Would love to interview you for the show if you are up for it. I dont have any viewers per se, but the episodes are a blast to make. Thanks again for all your help and advice! Looking forward to seeing more!
Hey, if it ain't broke, don't fix it! Didn't know you can't move the 'exit' object too far or you get problems, just figured it should work out theoretically ^^ I was watching some of your videos and I really like what you have going. It is well cut, you have multiple view angles to keep things interesting, and you seem to be getting the right people on who are interesting (or at least animated) in how they talk, giving the editor something to work with to keep the viewer engaged. There didn't seem to be a whole lot of structure to what's going on, but that's fine in it's own way. Just having the joke of nothing working to plan is fun in and of itself. However, the audio is really hurting it from being nice to watch properly. The different audio volumes makes it rather hard to listen to, as you come across way louder than the other people. Also, the mic hiss from others isn't ideal either, but the fix would mean you need to get them to record it locally, which isn't always possible or easy. I actually started work on a podcast tutorial to address the audio falloff, changing cameras and how to record an 'in world' camera. Unfortunately, vrchat broke part of the audio fall off when they did the massive accessibility features (specifically earmuff mode), causing the audio to go much louder instead of a seamless transition, so it got put off for the time being. Here's the prefab of it if you're interested (drive.google.com/file/d/149_1ODSJl0M2U5TRUZ6EE1tMaXs8Q8Zl/view?usp=share_link). I'm sure you will find the camera shader to be especially useful ^^ Lastly, and this is only if you're interested, I would love to come and have a look at your world and do some udon magic to help out. I really like what you have going, and while I may not be all that keen to come on the show specifically, I would love to help see this come to life. You really do seem to have something cool here, so keep it up! ^^
I have started putting together a world and I want to have music playing on a loop without buttons, in different rooms and I have audio distances set low and volumes low, but I still hear both songs together across the world no matter where I am, what am I doing wrong?
In this tutorial, I turn off spacialisation, in order to make the music sound like it's playing in our ears, instead of being from a point in the world. However, this also means that it doesn't have any sound falloff, which seems to be what your after. A simple fix for this would be to add spacialistation to your music, but then it will sound like it's coming from a point in space, which might not be what you want. Because of this, you might want to instead make a bunch of triggers in your world, that tell every other audioSource to stop playing, when you enter the room; and then tell your new music to start playing. Or, you could just get it to change the audioClip being played, which would avoid having heaps of audioSources Hope that helps ^^
This was a great tutorial, i followed it to upload 25 sounds into a sort of juke box,,, however can i add a script to automatically play the next song after the current one is done and to loop back through the entire list of audio objects? this would be the icing on the cake....
If I was trying to do that, I would approach the script differently. Have a script on the audioSource object itself, with an AudioClip[ ] of all the sound tracks. This means you can do all your logic here, to get it to move onto the next song and what not. Then whenever someone clicks one of the buttons, I would get it to tell that script the song they want to play with an int value, saying where that song is in the array. It would be a complete re-write of this script though...
Hi, thanks PlayerBush001 for a great and clear tutorial! About the music on/off toggle (single audio track): What would be the step to make the music to be always ON when the first player enters the world? (cannot obviously use play on awake?). After that, it would be on or off depending on the toggle function. I assume it is a true/false state question - but how to define that state to be ON for the first player? Any help with this would be greatly appreciated!
Thanks, glad you liked it ^^ As for making play by default, I'm assuming that your referring to the global one, as it would simply be 'play on awake' otherwise. For the networked one, we are determining the play state depending on the bool, which by default is off. The fix for this, is just to just change its default state. At timestamp 3:35, we can see that just below the sync toggle is where it shows the default state. Simply change this (and hit the compile button at the top right, as it won't auto compile), and the music should play by default. Hooe this helps ^^
@@PlayerBush001 Hi, thanks for taking the time to reply! Yes, now the music is off by default when the first player enters the world (it's a private world atm). I would like it to be on by default, and then react to the toggle function according to if the player chooses to switch it off. If he would choose off, it would be off for all players who enter the world. (during that session, not always). I'm not sure if this is possible. Using "Play on awake" means it will play for each player entering the world by default, right? Wouldn't the networking then be out of sync if someone has chosen to switch it off.
'play on awake' happens before any udon logic. If you have play on awake set to true, but then the networking sees that the 'isPlaying' bool is now false, then it will update the audio source to stop playing. I did miss in my answer that while you will want to change the default state of the bool, you do also need to tell it to play when the game starts by either hitting 'play on awake', or by plugging a 'event, start' node into the same arrow spot as the 'event, On IsPlayingChanged' node. Also, you can test the networking without uploading your world to vrchat. I show this in my most recent two tutorials, but if you build and test your world, and then once it's loaded past the anti-cheat screen, you can go 'last build', and it will load you into the same instance. There you can test with two players (even on the same account)
@@PlayerBush001 Hi again and apologies for disappearing for a while - was sidetracked from this project for a while. For some reason I did not get the 1st option working - if "play on awake´ is on, the music is on by default but the toggle button doesn't work anymore. But using the "event, On start" node worked! Thank you. 🙏 Will check the tutorial about testing the world without uploading, thanks!
Hello ^^ I believe the problem you are having is that your object doesnt have a collider on it. I actually made a YT short on this a couple of weeks ago: ua-cam.com/users/shortsJLepggh5B1U?feature=share Hope that helps ^^
@@PlayerBush001 i have a question tho. what if i want to add an ambient music that plays all the time, i tried just adding it in the project but switching or stopping musics will affect ambient sound as well.
Hello, I might be a bit late, but I'm using unity and everything and the place where I get my music for my vrchat worlds isn't letting me put them in unity anymore. ever since Ive started using SDK 3.0 unity doesn't like the music file where I get my music from. What should I do?
hmmm... depends on where the fault is, but here is what I would check: First, as a sanity check, can windows play the music file? Then, are you sure the music is actually playing? Forget about trying to use udon to play or pause the audioSource, can you play a normal audioSource that has the checkmark 'playOnAwake' ticked? If still no, have you tried also adding a vrcAudioSource component, and seeing if it works with one of those? If still no, I would check other music files from different sources (preferably from the unity store (there are free ones)), and see if they work. If they work, and it's just your music that's bugged, perhaps use something like Audacity to convert it into a .wav file, and see if that plays. Hope that helps ^^
HEllo! thanks for this tutorial. How would I modify this script to use sound effects? I have a rattle I want to rattle sound to, but I want it to play on pick up, but stop when it's put down. Another tutorial I would love to see is how to make an object invisible on pick up but still have it being held
Glad you liked it ^^ As for turning on and off the music when picked up, you just want to use the event `on pick up` and put that into a `audioSource.Play` node. Then to make it stop, you want to use the event `on drop` and put that into a `audioSource.Stop` node. The same thing can be done with making something invisible, but using the node `meshRenderer. SetEnabled`, with a public mesh renderer variable plugged into the instance slot. That being said, you may find that in your use case, that it's better to have it turn on and off when you 'use' the item you picked up, like I did in my latest torch tutorial. Hope that helps ^^
Ok so i've followed very carefully the tutorial. My sound plays once then goes mute. Example i have a world floor toggle to boot out anyone who is causing trouble in world. I press it and it toggles off the floor and everyone falls out of the world. I want the button to also play a sound. It works locally but not networked - hence the sound plays once. Also noticed that sounds on basic music buttons also have glitched in networked.
When an udon code only plays once, it's usually because the code is crashing (or perhaps your disabling the object it's on) That's most likely what's going on from what I'm reading, so I would recommend checkout my latest video on how to debug your code. If it is truly the networking, then it's probably an error hiding in plain sight. In that case, I would recommend asking in the vrchat official discord, as there you can post images, which makes debugging much easier
Not sure if you're still responding to comments here, but I have a question; For my world, I have multiple audio sources, as the music changes once you walk into a room. I was wondering, how would I make a toggle to turn off all of the music at once?
Depends on how you are doing the music, but you would either want use an audiosource[] or an audioclip[]. If the music has no specialization on it (plays in your ears, instead of from an object/point in the world), then I would just have 1 audioSource, and then change the clip of the audioSource to the new music track. For this, I would have 'music manager' script, with a public audioclip array on it; containing all the music tracks. Also have the target audioSource, and a public int that keeps track of what music track is playing. With those variables, create a custom event, that when called, gets the current clip in the array, changes the clip on the audioSource, and makes it play. (a similar script is shown in this video ua-cam.com/video/dmtftR4TefI/v-deo.htmlsi=gMiOLuXgkd3V63ym (though i randomized the int in the 'audioSource, get' node)) Then, create some trigger objects around your map, and 'event, on player trigger enter' --> 'playerapi, is local' --> branch -(true)->, get it to change the int on the 'music manger' script and then call the custom event. However, if you are instead making the music play from a point in the world, then things are a little more annoying. If you only have 1 audioSource per area, then you could just have an audioSource[ ], and cycle through all the audioSources; making all but your target one play 'audioSource, stop' and the target one play 'audioSource, play'. Alternatively, you could also just have them set to 'play on awake', and then cycle through a gameobject[ ], and toggle off the object/ parent objects with 'gameobject, set active' Hope this helps ^^
Hey man i know this may be old but looks like it works the same im getting a error and it says "VRCSDKBuildRequestedCallback" ,,,, could you help please
Thanks for reaching out, but sorry, I can say is that there is a problem with your sdk, as that isn't an udon error message. I would recommend asking on the official vrchat discord, as there are people willing to help there, that know more than me about these kind of errors
For future people trying to set up two clients to test this, VRChat's anti-cheat wont allow it. To fix it change your SDK Settings tab in the control panel to launch VRChat.exe instead of launch.exe.
so i have a music wall in my vrc world but the music is super quiet and i would love it it to cover the whole world when you click the button. but instead it only comes from the wall in which the button is placed- is there anyway i can fix this?
I say it quickly, but at roughly 0:35 I say: "I'm going to come into my vrchat audio source and hit this little dropdown menu, and disable 'enable spatialization'. This will make the sound play in our ears, instead of sounding like an object in our world."
The audio file was in my project window. You can drag and drop any compatible audio file (mp3, wav, etc) into your folder from windows explorer, and use it in your game/ world. If for some reason you dont have a project window, you can always create a new one by going 'windows, general, project' (or ctrl + 5). The project window/tab doesn't have to in that location though. It might be in a different location depending on your setup.
so i followed the steps for the first button and that worked but then the steps for the 2nd button didn't work at all for me because it gives me an error when click on the music changer button
does this script still work with newest sdk and udon 20.0. reason i ask is cause i tried your script that works in a previous sdk world however it no longer works
Thanks for the suggestion ^^ My tutorial on a basic 'toggling gameobjects' button should have been release like a month ago... but due to its larger size and bad timings, I've ended up having to scrap 2 recordings, mainly due to changes with my setup. Now that's all mostly dealt with, it should hopefully be out in a week or two. Have another roughly planned for selecting 'menus' which would be better for if you wanted to have a list of avatars, but no eta on that one.
If you just want it to play automatically, just set playOnAwake to true on the audio source As for making a play list, you most certainly can in udon, though you would want to approach it differently as to how I did in this tutorial. Your not the first to ask, so at some point I'll make a tutorial on it, but there are other topics I want to cover first
@@PlayerBush001 oh yeah as for the pedestals, i wanted to know how to make text appear above them so players know what character avatars are in the world (like their name)
Thanks for the question! There is a little technicality I would like to point out; buttons are not 'hooked', they are simply telling that audiosource to do something, rather than being linked. You can have as many buttons telling it to do however many things and it wouldn't matter. So to make a button that would stop it, simply create a new button, and then create a script with an interact event plugged directly into a audiosource.stop node. Now you have a button to tell the audio source to stop playing ^^
@@PlayerBush001 Thank you for the clarification. My first attempt I had created a button like yours with the script like yours to play and stop, then I created a second button with a similar script except to pause and play. But when I interact with the 2 buttons I get 2 instances of the audio playing and each button only plays/pauses or stops one of the 2 audios instances playing Perhaps plugging the interact node directly to the audio source as you mentioned, is going to fix that? I will give that a try. Thank you so much once again. Love your videos.
@@PlayerBush001 Also, is there a simple way to make the audiosource an updatable variable? I would like to have one play/pause button and one stop button, but change which audio source is loaded into the buttons. Like a record player that can load one track. This is for audiobooks I should point out. So I'm not really concerned with a playlist or multiple tracks.
Ah, forgive me if I'm wrong, but I don't think you went far enough through the video... If you have more than one audio clip that you would like to play, it should only be done with only one audio source, but change the clip being played on that audio source. In your case, you would only want another audio source if you wanted some other music playing in the background, or perhaps some bonus sound effects. The tutorial covers: (time stamps now added) - turning on and off on object - makes it networked - creates a button to change the clip being played - edits that button to avoid a bug - combines the play and stop button with the change music button, making them one - then finally making that new script networked (script get big...) You may like the final one better, but if I were to follow your description to a T, the two buttons before they are combined are exactly what you want. then you just need a new one that stops the audio source from playing. BTW, there are 4 nodes to consider: 'audioSource.Play', 'audioSource.Stop', 'audioSource.Pause', 'audioSource.UnPause'. Hitting either play or stop will reset the clip to the beginning.
@@PlayerBush001 Thank you for the responses and once again thank you for the video. No need for forgiveness, I guess I'm so anxious to learn I got to where you created the first script and then wanted to play around with it and try molding it into what I needed. I find that's the best way for me specifically to learn. But I can hold my further questions until I watch the rest of the video. It sounds like you will be addressing some of the things I'm trying to do :) Also, I will mention that right now I have a similar script to the first one you make except I'm using audioSource.Play and audioSource.Pause, on the same button interaction and the play doesn't reset the audio source. It works great for just playing and pausing the audio book. But perhaps it could still be beneficial to switch to the audioSource.UnPause, despite Play and Pause working the way I described.
@@PlayerBush001 thank you :D to be honest I'm new to this and I am trying to build a VR karaoke but I am having a hard time programing xdddd I am new to unity basically
Awesome! Though a lot of karaoke maps use video players instead audio files, to both allow for visuals, as well as get down the file size. Though things get a little awkward for quest...
It is local by default. There are two sections in the video (one for audio clip not changing, and then for when you are changing it) that add the extra nodes needed to make this global (see time stamps). Provided you don't do those steps, you will have what you want Hope that helps ^^
I plan on making a tutorial on a super basic vehicle sometime in the near future, but there's just too much that goes into make a good vehicle. 'Sacc's Flight and Vehicles' prefab has a military boat in it. Perhaps it might be of some use to you
Likely the public variables got lost in the conversion (happens from time to time due to unity being unity). Have a look at the object that has the script on it, and make sure all the public variables are filled in
@@PlayerBush001 The public variables were all good. I was able to find the actual issue though, the Interact Event just vanished lmao. I'm working on fixing it now. On another note, your tutorial is really helpful, so I appreciate it.
What part of the video are you trying to make? Is it just the play music script, or is the change clip script, or is it the play and change clip script? Also, when you click the button, do any debug messages pop up (seen in console if your using cyanemu, or 'Rshift + ` + 3' in vrchat)?
this is nice but maybe you can do a video that use one audiosource and more audioclips[ ] like klick and play and klick and change music like a list in one audiosource i tryet to make it work but i cant get it work so dificuld i dotn anderastad all notes
I did remember your comment, and unfortunately this script wouldn't be the right approach for what you are after (though you already knew that) While I was scripting, it didn't smoothly transition from the single audioSource script, to the method needed for what you would need for a music player, so I steered it towards those after looping music instead. I do have ideas for a video that covers making a music player, but I'm still rather inexperienced with video making, and this video really showed some areas where I need to optimize my recording setup/ methods; making a longer video rather tiring. So all in all, it will likely be a while before I make a music player tutorial. I would like to first cover some more topics, especially the super simple ones that anyone should know, but that I cant find a single tutorial on. Perhaps ask around on the VRChat discord, showing what you have got already, and get some pointers ^^
Can't add music, or don't know how? To use music in unity, first you need it to be on your project window. You can drag and drop any compatible audio file (mp3, wav, etc) into your folder from windows explorer, and use it in your game/ world. If for some bizarre reason you dont have a project window, you can always create a new one by going 'windows, general, project' (or ctrl + 5). The project window/tab doesn't have to in same location as mine though. It might be in a different location depending on your setup.
This video is a followup of my tutorial covering a more simple script, that tells an audioSource to play. From the sounds of it, this is more what you want: ua-cam.com/video/cQ3hWKY-NiA/v-deo.html
It's super interesting to see how Udon can be so complex but, at the same time, so easy to understand one someone knows how explain it. Amazing job as always!
Glad you think so! This was a much longer video than my previous vids, with much more going on, so breaking it down enough so that it didn't become overwhelming was a bit of a focus for it.
Glad it worked out ^^
Thank you so much for your help man! Such a simple and clear tutorial, I'll be sure to credit you for all this help
Glad you liked it ^^
Thxs so much i just was looking how to do this inew to udon and well
yo congrats 800 subs
i just subscribed and was your 800th
Thanks for the sub! Glad you liked the video ^^
This guy is SO underrated!
Thanks! ^^
The beauty of the UA-cam player is that I can change the playback speed when I want to see and hear things in the detail without telling the content creator to slow down.
Thank you so much! Thanks to you my world looks better !
Glad I could help! ^^
thank you so much, it saves me!
No problem! Glad it helped ^^
Hi, I'm always watching videos and I'm learning a lot thanks to you guys. Can you tell me the udon gimmick that makes a sound when the player enters the space?
@@annlice418 glad to hear your learning alot. Hope your having fun with it ^^
it's all about the event node that triggers the code to run. Have a look at my 4th (?) latest video all about events, as it should help show how to make different bits of code run at different times ^^
You're amazing, Keep it up!
Thanks! more to come ^^
Do you know how I can make a mute/unmute button that allows me to mute the music playing without stopping it?
Pretty sure you just use the node "audiosource, set Mute" (believe that's the name..) instead of "audiosource, pause". You could even make it a toggle by grabbing the current value (audiosource, get mute) and putting that through a "boolean, unary negation" node to flip the bool, and then set that as the bool value for the 'audiosource, set Mute' node.
(the other method would be to just change the volume to 0 (audiosource, set volume) ; proved you're not changing it anywhere else)
Hope that helps ^^
@@PlayerBush001Thank you!
im adding a sound to an asset in my world that i want people to be able to pick up and toggle the sound on and off but i want it to default off how would i do that? I followed this tutorial but it always plays as soon as i load in the world
On the audiosource component, there is a toggle called 'play on awake'. Turn that off, and it will no longer play when the game starts ^^
@@PlayerBush001 thank you!
thanks this helped alot,i only used first version with only one button.
haha, totally fine. Glad it helped! ^^
do you have a video on making a udon graph for triggering a one shot audio
Haven't use the node before, but looking at the documentation (and sorry I haven't tested it) it should work just like my 'how to play audio button' tutorial (ua-cam.com/video/cQ3hWKY-NiA/v-deo.html).
You will however need to tell it what clip to play (I would just use either a public audioClip variable or an 'audioSource, get clip' node), and you can also hit the dropdown to adjust the volume too.
Hope that helps ^^
what if I want it to be a trigger box that you walk into to play the music?
you would simply replace the 'event, interact' node with an
'event, onPlayerTriggerEnter' --> 'playerApi, isLocal' --> 'branch' -(true)->
As seen in my Jumpscare tutorial.
Hope that helps ^^
I'm trying to make a music box for my world so I was wondering if there was a way to make it where once you click the music box both the music will play, the handle will move, and once you click it again, it stops.
thanks bro!
No problem! Glad it helped ^^
is there a version where i turn all buttons into an automatic playlist?
i have an issue with this, when i join the world it automatically plays the audio, how do i fix this?
On the audiosource component, un-checkmark 'play on awake'
this weirdly doesnt work for me anymore... i dont know why. i booted up unity after a while and i did a map build and test, but i simply cant hear the sound... whatever i tried...
Check to see that the udon component hasn't forgotten it's values. Other than that, I'm not sure without asking a lot more questions. I would recommend asking on the official vrchat discord, where you can add photos to greatly help the debug process
When I play the audio... it doesn't go quiet when you walk away from it. It like its ignoring the min and max range :(
Thank you again! It seems that when the audiosource is not on a loop, and the audio ends, the button no longer works. I think the logic is flipping the bool somehow. If I catch the clip and stop it before it ends, I can play it again, but if it plays it self out, the button stops working. Any Advice?
Hmmm... That isn't right. However, this video covers a couple of scripts, so do you mind telling me at what time in the video you got the script from?
@@PlayerBush001 Thank you for responding! I should have followed the rest of the tutorial more. I ended up with exactly what you had in the end, I just had to do it the hard way. :D I usually have odd needs for my worlds that most of the tutorials work for but I end up having to tweak slightly, When I watched the first part, I was like, oh that is mostly what I need, Ill run with that. But it ended up working out. I am really grateful for your tutorials! I am working with another one, right now, the respawn changer. I run a VRC talk show, and wanted an eject button that would send the guest to another room, It took about 4-5 hours but learned that you cannot teleport a player, or respawn them when they are sitting. At least I havent figured out a way. So I ended up creating a script that teleports the chair and replaces it with a new chair, and does a bit of ring around the rosey. My Udon is not the cleanest but I am pretty proud of it. Would love to show it to you if you are interested.
You wouldn't be the first to not watch all the way through XD
As for why exactly it was crashing; when the audioSource went to change the clip, it was probably doesn't like the 'audioSource, stop' node. If it wasn't playing, the script likely crashed as it couldn't stop the audioSource. Glad you were able to come up with a decent solution on your own though, as that's better learning than any tutorial you could follow ^^
As for your chair problem, that is an interesting one. Now, unfortunately you can only teleport the local player. You need to instead tell the other player that they need to teleport, and get them to teleport themselves. However, there isn't any good way to tell a particular player to play some code. But, on the 'udonBehaviour, send custom networked event' node, it has the option to either tell everyone (all) to play the custom event, or just the owner of the object. So what you can do, is that when someone walks or enters a seat in your world, you can use the node 'networking, set owner' to make them the owner of the object. Then, when you need them to teleport, you can use the 'udonBehaviour, send custom networked event' node to tell them, the owner, to teleport outda there.
However, there are other methods too. If they are in a immobile station (aka, a chair), then you can move the 'exit' object to where you want them to leave, and then get them to leave the station and they will exit where the 'exit' object is.
Another method (if you haven't got them in a seat/station) is to activate a small trigger collider object right where the player's area is. Then, using 'onPlayerTriggerEnter', get it to teleport the playerapi. that would avoid needing to even keep track of who is there (just hope no other contestants enter the zone also. Then again, you could play a funny animation of something falling on them or something, to make it a funny fail instead).
But hey, that's just how I would do it. whatever works works. Just have fun with it ^^
@@PlayerBush001 The 'onPlayerTriggerEnter" box over the player is exactly what I had in place! I had two bits of code running there, one to spawn the box in and the other on the box to get them to teleport out. I would test it, and it would work fine, but then when they would sit in the chair, (in the same spot), they would stay put. It was driving me bonkers until I figured out that chairs were tricky that way, not a lot of info on that. Plenty of info on how to set up a basic chair, but thats about it. I guess no one is trying to do cheeky stuff with chairs, or if they do dont make tutorials on it :D
I remember seeing a comment or a bit in one of your videos about telling the player to tell themselves to teleport themselves, but I wasnt really sure where to start. I did see the customer networked event node with the tell everyone, but I hadnt thought to make them the owner, brilliant! Ill mess around with that in the next rev.
I thought about changing the exit point for the chair, but I read that VRC doesnt like when the exit point is too far away from the start, so I didnt bother.
Teleporting the chair seems to give me the behavior that I am looking for, I just swap out Chair one for chair two, and bobs your uncle, player disappears and a new seat is there. Then the ejected player can take their time to leave said chair and rejoin the group. Then if I need to eject another, chair two gets moved, and chair one is back in the beginning with some toggle logic. Would love to interview you for the show if you are up for it. I dont have any viewers per se, but the episodes are a blast to make.
Thanks again for all your help and advice! Looking forward to seeing more!
Hey, if it ain't broke, don't fix it!
Didn't know you can't move the 'exit' object too far or you get problems, just figured it should work out theoretically ^^
I was watching some of your videos and I really like what you have going. It is well cut, you have multiple view angles to keep things interesting, and you seem to be getting the right people on who are interesting (or at least animated) in how they talk, giving the editor something to work with to keep the viewer engaged. There didn't seem to be a whole lot of structure to what's going on, but that's fine in it's own way. Just having the joke of nothing working to plan is fun in and of itself.
However, the audio is really hurting it from being nice to watch properly. The different audio volumes makes it rather hard to listen to, as you come across way louder than the other people. Also, the mic hiss from others isn't ideal either, but the fix would mean you need to get them to record it locally, which isn't always possible or easy.
I actually started work on a podcast tutorial to address the audio falloff, changing cameras and how to record an 'in world' camera. Unfortunately, vrchat broke part of the audio fall off when they did the massive accessibility features (specifically earmuff mode), causing the audio to go much louder instead of a seamless transition, so it got put off for the time being. Here's the prefab of it if you're interested (drive.google.com/file/d/149_1ODSJl0M2U5TRUZ6EE1tMaXs8Q8Zl/view?usp=share_link). I'm sure you will find the camera shader to be especially useful ^^
Lastly, and this is only if you're interested, I would love to come and have a look at your world and do some udon magic to help out. I really like what you have going, and while I may not be all that keen to come on the show specifically, I would love to help see this come to life. You really do seem to have something cool here, so keep it up! ^^
I have started putting together a world and I want to have music playing on a loop without buttons, in different rooms and I have audio distances set low and volumes low, but I still hear both songs together across the world no matter where I am, what am I doing wrong?
In this tutorial, I turn off spacialisation, in order to make the music sound like it's playing in our ears, instead of being from a point in the world. However, this also means that it doesn't have any sound falloff, which seems to be what your after. A simple fix for this would be to add spacialistation to your music, but then it will sound like it's coming from a point in space, which might not be what you want. Because of this, you might want to instead make a bunch of triggers in your world, that tell every other audioSource to stop playing, when you enter the room; and then tell your new music to start playing. Or, you could just get it to change the audioClip being played, which would avoid having heaps of audioSources
Hope that helps ^^
This was a great tutorial, i followed it to upload 25 sounds into a sort of juke box,,, however can i add a script to automatically play the next song after the current one is done and to loop back through the entire list of audio objects? this would be the icing on the cake....
If I was trying to do that, I would approach the script differently. Have a script on the audioSource object itself, with an AudioClip[ ] of all the sound tracks. This means you can do all your logic here, to get it to move onto the next song and what not. Then whenever someone clicks one of the buttons, I would get it to tell that script the song they want to play with an int value, saying where that song is in the array. It would be a complete re-write of this script though...
@@PlayerBush001 now that would be a superb tutorial... hint hint.. cause I would need it🤣🤣🤣😁
Hi, thanks PlayerBush001 for a great and clear tutorial!
About the music on/off toggle (single audio track): What would be the step to make the music to be always ON when the first player enters the world? (cannot obviously use play on awake?). After that, it would be on or off depending on the toggle function. I assume it is a true/false state question - but how to define that state to be ON for the first player? Any help with this would be greatly appreciated!
Thanks, glad you liked it ^^
As for making play by default, I'm assuming that your referring to the global one, as it would simply be 'play on awake' otherwise.
For the networked one, we are determining the play state depending on the bool, which by default is off. The fix for this, is just to just change its default state. At timestamp 3:35, we can see that just below the sync toggle is where it shows the default state. Simply change this (and hit the compile button at the top right, as it won't auto compile), and the music should play by default.
Hooe this helps ^^
@@PlayerBush001 Hi, thanks for taking the time to reply!
Yes, now the music is off by default when the first player enters the world (it's a private world atm). I would like it to be on by default, and then react to the toggle function according to if the player chooses to switch it off. If he would choose off, it would be off for all players who enter the world. (during that session, not always). I'm not sure if this is possible.
Using "Play on awake" means it will play for each player entering the world by default, right? Wouldn't the networking then be out of sync if someone has chosen to switch it off.
'play on awake' happens before any udon logic. If you have play on awake set to true, but then the networking sees that the 'isPlaying' bool is now false, then it will update the audio source to stop playing.
I did miss in my answer that while you will want to change the default state of the bool, you do also need to tell it to play when the game starts by either hitting 'play on awake', or by plugging a 'event, start' node into the same arrow spot as the 'event, On IsPlayingChanged' node.
Also, you can test the networking without uploading your world to vrchat. I show this in my most recent two tutorials, but if you build and test your world, and then once it's loaded past the anti-cheat screen, you can go 'last build', and it will load you into the same instance. There you can test with two players (even on the same account)
@@PlayerBush001 Hi again and apologies for disappearing for a while - was sidetracked from this project for a while. For some reason I did not get the 1st option working - if "play on awake´ is on, the music is on by default but the toggle button doesn't work anymore. But using the "event, On start" node worked! Thank you. 🙏
Will check the tutorial about testing the world without uploading, thanks!
hi. i did everything as you did but it seems that i cant interact with the button, im not very familiar with unity so i have no idea whats happening.
Hello ^^
I believe the problem you are having is that your object doesnt have a collider on it. I actually made a YT short on this a couple of weeks ago: ua-cam.com/users/shortsJLepggh5B1U?feature=share
Hope that helps ^^
oh nevermind i fixed my problem, also your tutorial is awesome, thanks man.
Glad it helped ^^
@@PlayerBush001 i have a question tho. what if i want to add an ambient music that plays all the time, i tried just adding it in the project but switching or stopping musics will affect ambient sound as well.
If you create an audioSource on another object, it won't be effected by this script
Hello, I might be a bit late, but I'm using unity and everything and the place where I get my music for my vrchat worlds isn't letting me put them in unity anymore. ever since Ive started using SDK 3.0 unity doesn't like the music file where I get my music from. What should I do?
hmmm... depends on where the fault is, but here is what I would check:
First, as a sanity check, can windows play the music file? Then, are you sure the music is actually playing? Forget about trying to use udon to play or pause the audioSource, can you play a normal audioSource that has the checkmark 'playOnAwake' ticked? If still no, have you tried also adding a vrcAudioSource component, and seeing if it works with one of those? If still no, I would check other music files from different sources (preferably from the unity store (there are free ones)), and see if they work. If they work, and it's just your music that's bugged, perhaps use something like Audacity to convert it into a .wav file, and see if that plays.
Hope that helps ^^
hi, is there a way to link a youtube video instead of using a sound file?
HEllo! thanks for this tutorial. How would I modify this script to use sound effects? I have a rattle I want to rattle sound to, but I want it to play on pick up, but stop when it's put down.
Another tutorial I would love to see is how to make an object invisible on pick up but still have it being held
Glad you liked it ^^
As for turning on and off the music when picked up, you just want to use the event `on pick up` and put that into a `audioSource.Play` node.
Then to make it stop, you want to use the event `on drop` and put that into a `audioSource.Stop` node.
The same thing can be done with making something invisible, but using the node `meshRenderer. SetEnabled`, with a public mesh renderer variable plugged into the instance slot.
That being said, you may find that in your use case, that it's better to have it turn on and off when you 'use' the item you picked up, like I did in my latest torch tutorial.
Hope that helps ^^
Ok so i've followed very carefully the tutorial. My sound plays once then goes mute.
Example i have a world floor toggle to boot out anyone who is causing trouble in world.
I press it and it toggles off the floor and everyone falls out of the world.
I want the button to also play a sound. It works locally but not networked - hence the sound plays once.
Also noticed that sounds on basic music buttons also have glitched in networked.
When an udon code only plays once, it's usually because the code is crashing (or perhaps your disabling the object it's on)
That's most likely what's going on from what I'm reading, so I would recommend checkout my latest video on how to debug your code.
If it is truly the networking, then it's probably an error hiding in plain sight. In that case, I would recommend asking in the vrchat official discord, as there you can post images, which makes debugging much easier
Not sure if you're still responding to comments here, but I have a question; For my world, I have multiple audio sources, as the music changes once you walk into a room. I was wondering, how would I make a toggle to turn off all of the music at once?
Depends on how you are doing the music, but you would either want use an audiosource[] or an audioclip[].
If the music has no specialization on it (plays in your ears, instead of from an object/point in the world), then I would just have 1 audioSource, and then change the clip of the audioSource to the new music track. For this, I would have 'music manager' script, with a public audioclip array on it; containing all the music tracks. Also have the target audioSource, and a public int that keeps track of what music track is playing. With those variables, create a custom event, that when called, gets the current clip in the array, changes the clip on the audioSource, and makes it play. (a similar script is shown in this video ua-cam.com/video/dmtftR4TefI/v-deo.htmlsi=gMiOLuXgkd3V63ym (though i randomized the int in the 'audioSource, get' node))
Then, create some trigger objects around your map, and 'event, on player trigger enter' --> 'playerapi, is local' --> branch -(true)->, get it to change the int on the 'music manger' script and then call the custom event.
However, if you are instead making the music play from a point in the world, then things are a little more annoying. If you only have 1 audioSource per area, then you could just have an audioSource[ ], and cycle through all the audioSources; making all but your target one play 'audioSource, stop' and the target one play 'audioSource, play'. Alternatively, you could also just have them set to 'play on awake', and then cycle through a gameobject[ ], and toggle off the object/ parent objects with 'gameobject, set active'
Hope this helps ^^
Hey man i know this may be old but looks like it works the same im getting a error and it says "VRCSDKBuildRequestedCallback" ,,,, could you help please
Thanks for reaching out, but sorry, I can say is that there is a problem with your sdk, as that isn't an udon error message.
I would recommend asking on the official vrchat discord, as there are people willing to help there, that know more than me about these kind of errors
For future people trying to set up two clients to test this, VRChat's anti-cheat wont allow it. To fix it change your SDK Settings tab in the control panel to launch VRChat.exe instead of launch.exe.
so i have a music wall in my vrc world but the music is super quiet and i would love it it to cover the whole world when you click the button. but instead it only comes from the wall in which the button is placed- is there anyway i can fix this?
I say it quickly, but at roughly 0:35 I say:
"I'm going to come into my vrchat audio source and hit this little dropdown menu, and disable 'enable spatialization'. This will make the sound play in our ears, instead of sounding like an object in our world."
ok best video ever but how do i get the audio file where yours are
The audio file was in my project window. You can drag and drop any compatible audio file (mp3, wav, etc) into your folder from windows explorer, and use it in your game/ world.
If for some reason you dont have a project window, you can always create a new one by going 'windows, general, project' (or ctrl + 5). The project window/tab doesn't have to in that location though. It might be in a different location depending on your setup.
so i followed the steps for the first button and that worked but then the steps for the 2nd button didn't work at all for me because it gives me an error when click on the music changer button
ok so i got it working forgot to link audiosource to set clip for is playing lol
does this script still work with newest sdk and udon 20.0. reason i ask is cause i tried your script that works in a previous sdk world however it no longer works
It should work. There is nothing here that needs to be done differently, but perhaps the updating of the sdk caused it to bug out :\
can you make a tutorial for toggling avatar pedestals?
Thanks for the suggestion ^^
My tutorial on a basic 'toggling gameobjects' button should have been release like a month ago... but due to its larger size and bad timings, I've ended up having to scrap 2 recordings, mainly due to changes with my setup. Now that's all mostly dealt with, it should hopefully be out in a week or two. Have another roughly planned for selecting 'menus' which would be better for if you wanted to have a list of avatars, but no eta on that one.
@@PlayerBush001 oh yeah, would there be a way to have music automatically play in the world in some sort of playlist?
If you just want it to play automatically, just set playOnAwake to true on the audio source
As for making a play list, you most certainly can in udon, though you would want to approach it differently as to how I did in this tutorial.
Your not the first to ask, so at some point I'll make a tutorial on it, but there are other topics I want to cover first
@@PlayerBush001 i see, no worries!
@@PlayerBush001 oh yeah as for the pedestals, i wanted to know how to make text appear above them so players know what character avatars are in the world (like their name)
how would you have 2 buttons hooked up to the same audio source? That way you could have a play and pause toggle and a stop button.
Thanks for the question! There is a little technicality I would like to point out; buttons are not 'hooked', they are simply telling that audiosource to do something, rather than being linked. You can have as many buttons telling it to do however many things and it wouldn't matter.
So to make a button that would stop it, simply create a new button, and then create a script with an interact event plugged directly into a audiosource.stop node. Now you have a button to tell the audio source to stop playing ^^
@@PlayerBush001 Thank you for the clarification. My first attempt I had created a button like yours with the script like yours to play and stop, then I created a second button with a similar script except to pause and play. But when I interact with the 2 buttons I get 2 instances of the audio playing and each button only plays/pauses or stops one of the 2 audios instances playing
Perhaps plugging the interact node directly to the audio source as you mentioned, is going to fix that? I will give that a try. Thank you so much once again. Love your videos.
@@PlayerBush001 Also, is there a simple way to make the audiosource an updatable variable? I would like to have one play/pause button and one stop button, but change which audio source is loaded into the buttons. Like a record player that can load one track. This is for audiobooks I should point out. So I'm not really concerned with a playlist or multiple tracks.
Ah, forgive me if I'm wrong, but I don't think you went far enough through the video...
If you have more than one audio clip that you would like to play, it should only be done with only one audio source, but change the clip being played on that audio source. In your case, you would only want another audio source if you wanted some other music playing in the background, or perhaps some bonus sound effects.
The tutorial covers: (time stamps now added)
- turning on and off on object
- makes it networked
- creates a button to change the clip being played
- edits that button to avoid a bug
- combines the play and stop button with the change music button, making them one
- then finally making that new script networked (script get big...)
You may like the final one better, but if I were to follow your description to a T, the two buttons before they are combined are exactly what you want. then you just need a new one that stops the audio source from playing.
BTW, there are 4 nodes to consider: 'audioSource.Play', 'audioSource.Stop', 'audioSource.Pause', 'audioSource.UnPause'. Hitting either play or stop will reset the clip to the beginning.
@@PlayerBush001 Thank you for the responses and once again thank you for the video. No need for forgiveness, I guess I'm so anxious to learn I got to where you created the first script and then wanted to play around with it and try molding it into what I needed. I find that's the best way for me specifically to learn. But I can hold my further questions until I watch the rest of the video. It sounds like you will be addressing some of the things I'm trying to do :)
Also, I will mention that right now I have a similar script to the first one you make except I'm using audioSource.Play and audioSource.Pause, on the same button interaction and the play doesn't reset the audio source. It works great for just playing and pausing the audio book. But perhaps it could still be beneficial to switch to the audioSource.UnPause, despite Play and Pause working the way I described.
one question, if I want to upload the audio what format does it have to be? MP3?
You can look on unity to see what works. I often use wav, as somehow the file sizes seem to be smaller. Mp3 works as well
@@PlayerBush001 thank you :D to be honest I'm new to this and I am trying to build a VR karaoke but I am having a hard time programing xdddd I am new to unity basically
Awesome! Though a lot of karaoke maps use video players instead audio files, to both allow for visuals, as well as get down the file size. Though things get a little awkward for quest...
@@PlayerBush001 yo how do I get the audio files cause i don't know how
Is it something that will make trouble to make to quest?
This is fully quest compatible. No changes needed ^^
Is there a way to make this local only so only the player that clicks it can hear it and change it if they want to
It is local by default. There are two sections in the video (one for audio clip not changing, and then for when you are changing it) that add the extra nodes needed to make this global (see time stamps). Provided you don't do those steps, you will have what you want
Hope that helps ^^
@@PlayerBush001 so which sections do i skip if i want it to be local?
The two sections:
3:23 Make Toggle Global/ Networked
12:20 Make New Button Global/ Networked
@@PlayerBush001 Thank you :), can you maybe make a tutorial how to make a working boat next? I really need to make one
I plan on making a tutorial on a super basic vehicle sometime in the near future, but there's just too much that goes into make a good vehicle.
'Sacc's Flight and Vehicles' prefab has a military boat in it. Perhaps it might be of some use to you
My buttons stopped working entirely after I updated my world for Quest, so I am wondering if anyone knows a fix for this lmao.
Likely the public variables got lost in the conversion (happens from time to time due to unity being unity).
Have a look at the object that has the script on it, and make sure all the public variables are filled in
@@PlayerBush001 The public variables were all good. I was able to find the actual issue though, the Interact Event just vanished lmao. I'm working on fixing it now. On another note, your tutorial is really helpful, so I appreciate it.
@@atreecalledivan interesting. never heard of that happening, but nice one finding it ^^
Glad you're finding them helpful ^^
Hey i followed the steps and i did of it but i can't hear any of the music
What part of the video are you trying to make? Is it just the play music script, or is the change clip script, or is it the play and change clip script?
Also, when you click the button, do any debug messages pop up (seen in console if your using cyanemu, or 'Rshift + ` + 3' in vrchat)?
this is nice but maybe you can do a video that use one audiosource and more audioclips[ ] like klick and play and klick and change music like a list in one audiosource i tryet to make it work but i cant get it work so dificuld i dotn anderastad all notes
I did remember your comment, and unfortunately this script wouldn't be the right approach for what you are after (though you already knew that)
While I was scripting, it didn't smoothly transition from the single audioSource script, to the method needed for what you would need for a music player, so I steered it towards those after looping music instead. I do have ideas for a video that covers making a music player, but I'm still rather inexperienced with video making, and this video really showed some areas where I need to optimize my recording setup/ methods; making a longer video rather tiring.
So all in all, it will likely be a while before I make a music player tutorial. I would like to first cover some more topics, especially the super simple ones that anyone should know, but that I cant find a single tutorial on.
Perhaps ask around on the VRChat discord, showing what you have got already, and get some pointers ^^
@@PlayerBush001 ok thx :)
i need to no how to play 10 songs on one cube
nice maybe upload a preflab from this
Feel free to ^^
Personally I'm not to keen, as people would expect it to be kept updated
i can't add music
Can't add music, or don't know how?
To use music in unity, first you need it to be on your project window.
You can drag and drop any compatible audio file (mp3, wav, etc) into your folder from windows explorer, and use it in your game/ world.
If for some bizarre reason you dont have a project window, you can always create a new one by going 'windows, general, project' (or ctrl + 5). The project window/tab doesn't have to in same location as mine though. It might be in a different location depending on your setup.
Why can't you just do a SIMPLE click and play, without all the other crap.... I click button it plays.
This video is a followup of my tutorial covering a more simple script, that tells an audioSource to play. From the sounds of it, this is more what you want: ua-cam.com/video/cQ3hWKY-NiA/v-deo.html
Thank you for making these videos. Any change you would give me the time of day to return the favor ?