You have a gazillion problems. I've editted your script and added some comments. Maybe watch some of the scripting tutorials on the Learn site.
A common mistake is you do not write if statements correctly:
if (condition){
// code it execute if the condition is matched
}
Note the opening brace following the condition, and the closing brace that is aligned with the if. This makes the code readable. You can also use:
if (condition)
{
// code it execute if the condition is matched
}
I personally think opening braces on a line all by themselves makes the code longer.
Also every opening brace has a matching closing brace. Functions start and stop with them:
function doit() {
// code for the function
}
Note that all of this is general programming lessons, it's totally unrelated to Unity.
↧