I get an error message saying: Assets/Scripts 1/Audio upon death.cs(1.36): error CS8025: Parsing error
The script that i wrote is trying to get an audio file to play in it's entirety and re spawn my character when it finishes. Can anyone help me find the error? (soz i'm pretty new to scripting.)
public AudioClip "Death Song";
public float length 10;
Answer by Mike 3
Oct 25, 2010 at 11:55 AM
The top line is the one with the problem, you're trying to use a string literal as a variable name
Change it to something like this:
public AudioClip deathSong;
It'll let you assign the audio clip from the inspector after that
Same with the line below it. Or, you can put an equals sign before the constant in both cases. The variable will default to that value when the script is first assigned to an object, but after that whatever value you assign it in the Inspector will be the one that sticks.
You couldn't put an equals sign on the top line, there isn't a string to AudioClip conversion. But yeah, would work on the second line
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
No one has followed this question yet.
Script Errors with C#
How to fix my code? (Player death + Respawn)
Music stops other sounds from being played?
Warning: "Can not play a disabled audio source"
Error trying to get audio to play when pressing jump button