Hello I made a simple script in unity. I wanted to hit a trigger and let a gameobject deactivate. Another part of the script deactivates another gameobject if the first is already deactivated. This script does not work.
Also, I am using a 3.X version of unity.
var Key : GameObject;
var Blocker : GameObject;
function Start () {
Key.active=true;
Blocker.active=true;
}
function Update () {
if(Key.active=false){
Blocker.active=false;
}
}
function OnTriggerEnter () {
Key.active=false;
}
function Update () {
if(**Key.active=false**){
Blocker.active=false;
}
}
one equal sign ( = ) is assignment,
If you want to test for equality you need to use a double equal sign ( == )
So it would look something like
if ( Key.active == false ) { }
Also, considering you only change the state of Blocker to inactive when key is inactive, there’s no reason to do this in the update loop. You can just as easily change both states in your OnTriggerEnter method