THANK YOU! I spent over two hours reading and watching tutorials trying to get a simple sound to play on collision, but they were all too complex for a beginner. This is exactly what I needed, and now it works. Thank you so much. ^_^
@matanyamin1
2 жыл бұрын
That is exactly what I was thinking! Thank you M Murad.
@Emma-bq5br
3 жыл бұрын
So helpful! I was making it out to be so much more complicated than it actually was. Thank you so much!
@ridgemills
4 жыл бұрын
Haha this is actually my first code that actually worked. Started in Unity two days ago. Happy as a child.
@kamilorado6979
6 жыл бұрын
Dude, u explain it so simple and easy. Thanks!
@anthonycollins7992
5 жыл бұрын
Good tut, thanks. Do you have anything on setting up sound for rolling objects? I'm struggling getting it set up. thanks!
@witchofheart2000
5 жыл бұрын
you. SAVED MY LIFE. THANK YOU
@robertnewton9548
5 жыл бұрын
So helpful. So simple and well explained. Thanks!
@miosz5390
4 жыл бұрын
Good job. That's what I was looking for.
@GaryParkin
5 жыл бұрын
Thank you so much, that was quick and easy. I did find out I don't need the init code in Start() if I drag and drop my AudioSource component onto the variable in the main component.
@mmuradiqbal-technuggets-ja3597
5 жыл бұрын
Glad it helped
@turkym7md5
6 жыл бұрын
On PC it playes right when I hit but when I export it to android it takes a delay after the collision happens and playes the audio Why did that happen?
@BloxzillaYT
Жыл бұрын
Ty, this helped me alot! I love that explosion thing too.
@viptsv2665
5 жыл бұрын
Nice video! Short, clear and useful. But it will be very hard for begginers to understand it. You could make the sound play on button click, so it's more simple for newer programmers.
@HirenWolf
6 жыл бұрын
Thanks a lot, helped me out a bunch!
@HirenWolf
6 жыл бұрын
XD That is by far the best reply I've ever had.
@yuval5231
6 жыл бұрын
Great explanation! Helped me a lot.
@mmuradiqbal-technuggets-ja3597
6 жыл бұрын
Glad it did
6 жыл бұрын
thanks man it worked! :)
@fallondriade
4 жыл бұрын
thank you so much, it worked and it was easy to follow
@jaristudios4207
5 жыл бұрын
Thank You! You saved me :)
@ConcreteJungleGames
3 жыл бұрын
Great tutorial Murad, thanks for uploading!!!
@mmuradiqbal-technuggets-ja3597
3 жыл бұрын
Welcome
@Sonsho
6 жыл бұрын
What if I have 2 sounds, (one is the main theme that's gonna loop, the other is a loot sound) Do I make different scripts?
@TolgaDurman
5 жыл бұрын
Create a gameobject and add audio source to it then sellect loop if you wanna disable when the thing that plays tick sound add gameobject under it create a prefab and destroy the gameobject with the thing plays thick sound.
@Tutterzoid
5 жыл бұрын
Only 1 script needed for the loot sound. Attached the loop sound to the camera :)
@thegamedevshow8449
4 жыл бұрын
the one that's gonna loop put it in the camera and make it a seperate script and on the script put DontDestroyOnLoad(); and make it loop the second make it as a seperate script
@CalmingWinds
4 жыл бұрын
Works great! Thanks!
@liyunliu7609
5 жыл бұрын
Thank you, excellent!!
@YashchiK
4 жыл бұрын
good but don't understand how to add different audio to one audio source and change them from script/ For example if I have two audio which should play alternately in the one object
@JoeAC5000
4 жыл бұрын
Is anything different if your making a 2d game?
@saziahboodoo1196
3 жыл бұрын
why there's cannon near the main camera in the hierarchy??
@syedmuhammadaliraza3069
4 жыл бұрын
why we needed to assign it again in start fun ,,as we referenced it already..
@milomakesstuff2019
4 жыл бұрын
Thank you very much! Greetings from The Netherlands!
@mmuradiqbal-technuggets-ja3597
4 жыл бұрын
Most welcome
@avischiffmann6220
4 жыл бұрын
perfect thank you!
@collosalcake236
2 жыл бұрын
thank you! This was so helpful!
@mmuradiqbal-technuggets-ja3597
2 жыл бұрын
Welcome
@KalifasTMProduction
3 жыл бұрын
O M G !! Thank, after one hour reading tuto from web, you make best tutorial !! (Sorry for my english, i'm french) ♥
@mmuradiqbal-technuggets-ja3597
3 жыл бұрын
Welcome
@dertyluck
2 жыл бұрын
Thank you very helpful!
@bnebbneb2292
4 жыл бұрын
What a legend.
@TheNamesJT
4 жыл бұрын
This is only showing how to play one sound? For my game wanting to have 2 for it to switch between upon collision...
@eleanordare7204
6 жыл бұрын
great - very simple and clear - worked perfectly :-)
@mmuradiqbal-technuggets-ja3597
6 жыл бұрын
Glad you liked it
@beastmasterbg
4 жыл бұрын
ok this working if its only one sound but if there are two sound how do I attach it because the get component doesnt find the sound
@direncuyanik7
3 жыл бұрын
Yo can add a public game object and you can attach your sound to that object than you can get the audio source of that gameobject. İt's working. Example: public AudioSource sound; public AudioSource sound2; public GameObject plane; sound = GetComponent(); sound2 = plane.GetComponent(); I hope it will work in your's too!
@mr.shroom4280
3 жыл бұрын
You're amazing, i love you
@thoaihoquang1578
5 жыл бұрын
It is does not work on prefab
@Kingstantin
Жыл бұрын
Strange, I started with the very same code as you. When I add to play Auto, it didn't give me any error message but when I play, my objects will be destroyed by touching the ground! Why... I got exactly the same code as you. If I delet that Audio part, everything works fine again.
@greenvans7
4 жыл бұрын
Can someone explain the tag portion
@shrom6753
2 жыл бұрын
the audio seems delayed from when i come into contact with the object
@gamingdojo6126
2 жыл бұрын
Mashallah , may allah give you happiness , i was looking for this tutorial for about 15 minutes !! Thankyou so much
@mmuradiqbal-technuggets-ja3597
2 жыл бұрын
Hayyak Allah
@vikeyto
4 жыл бұрын
best and simpelst solution....thank you
@publicstaticvoid3224
5 жыл бұрын
Thank you very much!
@imsleepingbtwlol
Жыл бұрын
broooo dude, thankk you. I legit spend 5 hours trying to find outt how to add the sound component.
@yashuapervez1533
5 жыл бұрын
Thanks for the help
@catty7060
5 жыл бұрын
tnx , what is your keyboard ? the sound of it is great :D
@mmuradiqbal-technuggets-ja3597
5 жыл бұрын
MacBook pro retina
@lauradcamelo221
3 жыл бұрын
hi, thanks for the video, but, someone can tell me , is "ticksource the name of the audioclip" ? because in my code shows : " the name ticksource doesn´t exist in the context.
@mmuradiqbal-technuggets-ja3597
3 жыл бұрын
tickSource is the variable name I used. And then dragged and assigned the audio clip to it. Hope this helps.
@SonicDXNero
5 жыл бұрын
Thank you my friend! :D
@mmuradiqbal-technuggets-ja3597
5 жыл бұрын
Welcome dear
@ry_n007
Жыл бұрын
bro came in clutch
@bonbondolly
Ай бұрын
Superhelpful! Thank you!
@andreasfrailich2612
4 жыл бұрын
 New I have a problem of my own, I have recently had sound problems for no reason at all, this is a complaint I have always had with unity(the fact that the software creates its own problems out of the blue) my sound always worked fine, for the 2 years so far that I have been developping my game. But now for some reason not only does it glitch and sound buggy, if it even plays at all. Two different sounds wont play at the same time. I have a boss fight with music and roars froms the boss. Everytime he roars the music cuts off and I hate how that happens. It ruins the effect of the battle. Inside unity there appears to be no visible problem, everything gets ticked on at just the right time but for some reason it s does not work. I have spent years on this game, I wont have it ruined by unity problems please help
@usernotseen4911
4 жыл бұрын
Make a backup of your Unity project and reinstall Unity. Then, import your project back into Unity and it should be fine.
@muhammedsarigul5508
3 жыл бұрын
Thank you so much!!!
@mmazuk1958
2 жыл бұрын
Thanks for tutorial!
@mmuradiqbal-technuggets-ja3597
2 жыл бұрын
Welcome
@MCGameriSrbija
7 жыл бұрын
thank u man :D But I have one question. I am making a game called "roll a ball" U have a ball[player] and pickups. With this that u shows me I maket a sound effect when player pickup the pickup. So how now to make a wins sound effect.It need to be in a same script and it need to bi on a same player so idk how to separate them ins script?Please help and thanks :D
@mmuradiqbal-technuggets-ja3597
6 жыл бұрын
I am sorry I was not able to respond. Did you get through it ?
@MrWolfMRW
6 жыл бұрын
there are already 100000 games called roll a ball heck even one steam tutorial is caled like that
@GeorgTheGr8
6 жыл бұрын
First, give the pickup prefab the tag "Pickup", give the player object an AudioSource component and then paste this in the player movement script: void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Pickup")) { other.gameObject.SetActive(false); GetComponent().Play(); } } I hope this helps!
@WhaffleTV
6 жыл бұрын
i did this, and it says that "GetComponent" dosen't exist, please help
@AetherXIV
4 жыл бұрын
this works well and is nice and simple. however my script destroys the bullet as well and thus the audiosource clips out before it can finish playing. Yours works because your "bullet" isn't removed. I'll have to find a workaround
@mmuradiqbal-technuggets-ja3597
4 жыл бұрын
Place the audio clip in an empty object
@AetherXIV
4 жыл бұрын
@@mmuradiqbal-technuggets-ja3597 thanks for the reply. I tried that but then failed at refrencing it and getting it to play after I set it to not play on awake because I don't want random sounds at the start of the game
@mmuradiqbal-technuggets-ja3597
4 жыл бұрын
@@AetherXIV Did you try taking the empty object as a reference to the script?
@AetherXIV
4 жыл бұрын
@@mmuradiqbal-technuggets-ja3597 thanks for the reply! got it working :)
@BladeArtOffline
6 жыл бұрын
how to i use without adding the audio in void update()
@mmuradiqbal-technuggets-ja3597
6 жыл бұрын
if you want to use it in the update() you have to either assign a reference at the top like I did or you can do getComponent in the update method.
@luc_verse
3 жыл бұрын
I am getting this error... Help me ArgumentNullException: Value cannot be null. Parameter name: source UnityEngine.AudioSource.Play () (at :0) Collector.OnCollisionEnter (UnityEngine.Collision collision) (at Assets/Mine/Collector.cs:16)
@harryelliott6945
3 жыл бұрын
Great tut
@KCWeather
2 жыл бұрын
Thank you :)
@264games2
3 жыл бұрын
Thanks dude
@gamedev_navneet
4 жыл бұрын
Thank-you 🤓👍
@batoybatoy_piks6214
7 жыл бұрын
Thanks!
@mmuradiqbal-technuggets-ja3597
6 жыл бұрын
My pleasure
@thefrontenddeveloper9984
5 жыл бұрын
Thanks...
@niojackson938
4 жыл бұрын
its still not working for me...not sure what im doing wrong
@geoskango8873
4 жыл бұрын
Same for me
@mrunmaymycode748
3 жыл бұрын
Thank you so much
@mmuradiqbal-technuggets-ja3597
3 жыл бұрын
Welcome
@ieatyoursushi7655
4 жыл бұрын
that saved me
@buddyroach
3 жыл бұрын
doesnt work for me
@rezamohammadiyan1413
3 жыл бұрын
thanks mate
@kamillatocha
6 жыл бұрын
how do i add tags
@mmuradiqbal-technuggets-ja3597
6 жыл бұрын
Click on the gameobject in your scene, then in the Inspector on the right side look at the top, there should be a Tag combobox / drop down which is by default untagged. Click to expand it and Add a Tag. Hope this helps.
@LeminSpeedrun
5 жыл бұрын
thanks
@davidbielsa5188
4 жыл бұрын
What about an object having different sounds depending on different things that the object does? spawning, hitting the floor, hitting an object, being destroyed, etc. In the video it seems that it is not possible to do this, i.e. only 1 sound per object.
@finley9553
3 жыл бұрын
just add different triggers to the script
@helixgaming352
6 жыл бұрын
Hey man could u link the code in the description? Thanks!
@Tutterzoid
5 жыл бұрын
Wow! If you can't type out such a short bit of code, then maybe you shouldn't be doing programming ...
@levichan1558
5 жыл бұрын
true ture @@Tutterzoid
@Snakeybus
3 жыл бұрын
can anyone send me the code so i don't have to type it
@randommoose6550
2 жыл бұрын
You've been waiting nine months just so you don't have to type a few lines of code. That's determination right there.
@TakaShitake-rt8bz
10 ай бұрын
but please - I need for bullets that get destroyed ALSO - so please update your tutorial with the fix to show how to handle for canon ball that ALSO GETS DESTROYED this is the crux of the issue my friend.
@mmuradiqbal-technuggets-ja3597
10 ай бұрын
Thanks for watching, will resume making soon.
@minotoror_
5 жыл бұрын
For those that couldn't get the audio to work try removing the Start() function completely. So it should go... From this: public AudioSource tickSource; void Start () { tickSource = GetComponent (); } void OnTriggerEnter2D (Collider2D collision) { if (collision.gameObject.tag == "Target") { tickSource.Play (); Destroy(gameObject); } } To this: public AudioSource tickSource; void OnTriggerEnter2D (Collider2D collision) { if (collision.gameObject.tag == "Target") { tickSource.Play (); Destroy(gameObject); } } This is how I got it working for me. Remember to make a Audio Source component and pass it in to tickSource or whatever you name it on Unity.
@kiranvenugopalan3331
2 жыл бұрын
much appreciated!!
@TheSuperJiJo
2 жыл бұрын
Thank you
@mmuradiqbal-technuggets-ja3597
2 жыл бұрын
Welcome
@vaak2144
4 жыл бұрын
tnx boi
@uber6604
3 жыл бұрын
not working
@v3vlog
5 жыл бұрын
Dude I need ur all scripts ? Can I get?
@mmuradiqbal-technuggets-ja3597
5 жыл бұрын
Exactly which ones?
@v3vlog
5 жыл бұрын
@@mmuradiqbal-technuggets-ja3597 the scripts u used in this clip
@HerobrineTNT
5 жыл бұрын
Playback speed 0.75
@foxfirefive
3 жыл бұрын
GUYS HERES THE CODE! YOU HAVE TO CHANGE A FEW NAMES AND STUFF BUT IT DOESNT WORK FOR ME BUT IT MIGHT WORK FOR YOU! using System.Collections; using System.Collections.Generic; using UnityEngine; public class ImpactScript : MonoBehaviour { public AudioSource tickSource; void Start() { tickSource = GetComponent (); } void Update() { void OnCollisionEnter (Collision collision) { if (collision.gameObject.tag == "Object") { tickSource.Play(); } } } }
@foxfirefive
3 жыл бұрын
GUYS YOU CAN ALSO TRY THIS THIS ONE WORKED FOR ME using System.Collections; using System.Collections.Generic; using UnityEngine; public class ImpactScript : MonoBehaviour { public AudioSource ImpactSource; void Start() { ImpactSource = GetComponent (); } private void OnTriggerEnter2D (Collider2D collider) { if (collider.gameObject.tag == "Object") { ImpactSource.Play(); } } }
@Mikelica69
3 жыл бұрын
71.743 visualizaciones•15 may. 2017 777 77
@danismeu555
4 жыл бұрын
ZA CANUNBUL
@rathodketan5551
4 жыл бұрын
this is work 🤣🤣🤣🤣🤣
@djkorou
3 жыл бұрын
111th comment
@christiandonato9005
4 жыл бұрын
curry curry...
@snowballvr6561
2 жыл бұрын
public Audiosource TickSource; tickSource = getcomponet (); TickSource.play ();
Пікірлер: 134