I get this error:
when doing this:
I get this error:
when doing this:
You have “;” after your if test and before your if code.
function Update() {
distance = distance +Time.deltaTime;
if(distance>3)
transform.Translate(0, 0, -2 * Time.deltaTime);
if(distance<3)
transform.Translate(0, 0, -2 * Time.deltaTime);
}
Thanks! I just learned my dad is a JAVA coder, so this will be helpful in the future. And this worked. I am going to say that this script can be copyed and pasted if anyone wants it. Again, thanks Ozwizart.
Don’t be lazy! Always include braces. Always.
if (a > b) {
a = 0;
}
Yes you are right, I omitted them because there was also a problem with braces placement in the first post and I thought it would simplify the answer, won’t do it again :).