Sorry if i failed on a stupid thing, i am getting a error :
1.(9,22) expecting ), found “=”.
2.(9,24) unexpected token: 1.
3.(10,27) expecting :, found “;”.
i tried to resolve this error but i don’t understand what is wrong in the script
var RandomPos:float;
InvokeRepeating("RandomPosFunc",0,2);
function RandomPosFunc () {
RandomPos=Random.Range(1,5);
}
function Update () {
if(RandomPos = 1){
print("1");
}
}
you set it as C# code?
When it is Unity Javascript code
This is unity script/javascript
i am sure i isn’t a c# file
exactly, what I was trying to say.
Thought you might have made it as a C# file.
= is a variable assignment
== is “equals to”
since you can’t assign a var within the brackets of an if block the compiler is trying it’s best… so it’s expecting “if(RandomPos)” ie ) instead of = and then well… the rest stems from that really.
edit: holds for c# and unityscript
LeftyRighty:
= is a variable assignment
== is “equals to”
since you can’t assign a var within the brackets of an if block the compiler is trying it’s best… so it’s expecting “if(RandomPos)” ie ) instead of = and then well… the rest stems from that really.
edit: holds for c# and unityscript
oh yeah…how supid i am , i haven’t used unity for a while so i forgot