- Home /
How do I fix my game after API failing to update my scripts
I hadn't been on my game for 3 months and just found about about unity 5 so I decided up update and was greeted with API failing to update my scripts. There are 55 errors I don't understand any of them, they tell me to use Use GetComponent([less than sign]AudioSource[more than sign]() instead. There are many other errors similar to this but I guess I should start on this one. I have no idea where to put this code so I did this.
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "Player")
{
gameObject.SetActive(false);
GetComponent<AudioSource>();
audio.PlayOneShot (coinSound);
count = count + 10;
SetCountText ();
}
}
The errors this dramatically dropped from 55 to 3 which were; Unexpected token: ). expecting ), found ';'. ';' expected. Insert a semicolon at the end. I have look everywhere on the internet and have had no help, surely thousands of people have had this problem when upgrading from 4 to 5, I'm afraid that when I fix this I will have to deal with 50 more, I don't want to ask 50 questions on here
Answer by CowNecromancer · Apr 21, 2015 at 02:42 PM
change if(col.tag -- "player)
to
if(col.transform.tag == "player")
Answer by Goofy420 · Aug 06, 2015 at 10:32 AM
Line 6 is invalid and line 7 is outdated Remove line 6 and change line 7 to: GetComponent().PlayOneShot(coinSound);