Help ep. 11 sound error

Updated on December 27, 2016 in [A] Audio
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
6 on December 24, 2016

Help plz I have error which is saying: https://gyazo.com/cac0338fec88e93986ff73b06a170b88

Script: https://gyazo.com/24b91a98e453a5269d479066d43697c8

  • Liked by
Reply
0 on December 24, 2016

plz

  • Liked by
Reply
Cancel
0 on December 25, 2016

So Unity accesses the audio differently than it did when this tutorial was created.

So what you should do instead is create a variable at the top:

var audio : AudioSource; // just under or below the line with 'var maxFallDistance'

then change your line 15 to 
audio = GetComponent(AudioSource);

You should be good to go from here, but again, this tutorial was made with an outdated version of Unity so you’ll probably see things like this a lot. If you have troubles with things like this again, I’d suggest checking out the Unity Scripting Docs for reference or google searching for updated information on unity tools first, before asking these questions. Just because it would probably help you out quicker next time. Of course though, if you still can’t find it after looking for it yourself, well, that’s why this forum exists!
Good luck!

  • Liked by
Reply
Cancel
0 on December 25, 2016

Now have this error: https://gyazo.com/124865750cf9e250d2226309e80af73c

sript (now): https://gyazo.com/682b07bb209af8ff6e917c9f257d367b

  • Liked by
Reply
Cancel
0 on December 26, 2016

hmm… looks like ‘audio’ wasn’t unique enough. Try changing ‘audio’ to ‘restartAudio’ or just whatever you want. Make sure it’s more unique than just ‘audio’ though.

  • Liked by
Reply
Cancel
1 on December 26, 2016

Fixed it!

I used restartAudio and it first said that it is unidentyfied (Sry for english) then I was thinking about making variable restartAudio and then it worked!

Devoted
on December 27, 2016

But, just a small thing…
Instead of setting restartAudio every time you restart, set it at the Start function and just use it whenever needed.

And why did you add the comment BinaryBeal put when he made the variable? It was there just to tell you where to put it, it’s really bad to put it there anyways.

Show more replies
  • Liked by
Reply
Cancel