If you click on the errors it’ll go to the line they’re in. As you can see, the problem is in line 15, and it has a red mark blow the “:”. You probably used to write code in javascript and use the “:” to tell unity what’s the class of the object. In c# you don’t decleare the class like this:
other : Collider;
instead you put the class first an then the name you want to use, like this:
Collider other;
Also, you don’t use the keyword “function” you just put the return type, that is the class you want to return. For example, if your function is an adition and it returns a number, you use “int”.
So it’ll be like:
int firstNum = 3; //you put the class first
int secondNum = 4; //you put the class first
//"public" as in other scripts can use it.
//"int" because this function returns an int
//"MyAddition" is the name, you can choose whatever
//"(int a," is the first parameter, as you can see the class is expressed first, then the name
//"int b)" is the second parameter, again the class is expressed first, then the name
public int MyAddition(int a, int b)
{
return a + b; //as you can see it returns an int
}
If your function doesn’t return a thing, you just use “void”. That’s what you should have used here.
So, to sum it up, you change the line 15 to this:
void OnTriggerEnter (Collider other){
You’re mixing UnityScript code (which is obsolete) with C# code.
This is the C# equivalent of OnTriggerEnter:
First off, use the code tags, it makes everything much easier to read and deal with, you can just copy and paste it into the forum post. This looks a lot like Javascript so no wonder you’re having problems, Unity has made Javascript obsolete so if you’re looking at old tutorials that will no longer work, make sure to look for C# tutorials only.
Try this
Private Void Function OnTriggerEnter (other collider )
{
if (other.tag == "coin"
{
score += 5;
Destroy (other.gameobject);
}
}
I haven’t tested this code and only done a quick write up, let me know if you have problems, you need to also put the score up at the top as an public integer and then it should all work fine, that being said I think they put in recently a way for you to write shorthand so experiment and see if it works regardless.
I think you’re looking at some very outdated tutorials there.
Edit: LOL I had just finished my post and of course two others got there before me I suspect just checking out the up to date tutorial link will be easiest.