void OnTriggerEnter2D(Collider2D other) { Debug.Log("Someone entered the switch trigger"); theSwitch.turnOn(); theBulb.turnOn(); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) == true) //has spacebar been pressed { if (theSwitch != null) //the variable f the switch is equal to nothing (if it hadnt been wired up), if u made a mistake and didnt drag it over, call the function on the switchcontroller script { theSwitch.toggleSwitch(); //it would work perfectly only if u wired it up, this is just in case it hasnt if (theBulb.bulbOn == true) { theBulb.turnOff(); } else { theBulb.turnOn(); } } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) == true) { if (theSwitch != null) { theSwitch.toggleSwitch(); if (theBulb.BulbOn == true) { theBulb.turnOff(); } } else { theBulb.turnOn(); } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) == true) { if (theSwitch != null) { if (theSwitch.switchToggle == true) { ; } { if (theBulb.LightOff == true) { theBulb.turnOn(); } else { theBulb.turnOff(); } } } } }
public void turnOn() { switchOff = false; switchAnimator.SetBool("SwitchOff", switchOff); bulbController.turnOn(); }