Is it not possible in UnityScript to change the value of a boolean variable with the NOT operator?
This is what I would expect:
var x = true;
var y = true;
var x = !y;
//variable x is now false
Is this not something you can do in UnityScript? I believe it works in regular JavaScript…
You are redeclaring variable x, otherwise your example will work. The problem is that your variable is probably overridden from inspector.
Im a c# programmer mostly, but i tried this example and is works perfectly.
private var x:boolean = true;
private var y:boolean = true;
private var a:boolean = !y;
private function Start():void{
Debug.Log(a); //prints false
}
Sure you can. It works as expected, though you need to remove “var” from the third line since you can’t declare the same variable twice.
Remove the var in
“var x = !y;”