Simply turning off a light via a colision with a button and on collison with another turning back on… However it’s not working. The light turns of fine, but does nto want to turn back on… annoying.
The code uyou see below is an evolution of a previous answer
the light script:
private var on = false;
function Start(){
var someScript1 : lightingswitchScript;
someScript1 = gameObject.GetComponent("lightingswitchScript");
var someScript2 : lightingswitchScript2;
someScript2 = gameObject.GetComponent("lightingswitchScript2");
}
function Update () {
if (lightingswitchScript.lighttouch == true){
lightoff();
}
if (lightingswitchScript2.lighttouchh == true){
lighton();
}
}
function lightoff (){
if (lightingswitchScript.lighttouch == true){
if(on == false){
light.intensity =0;
on = false;
}
else {
light.intensity =2;
on = true;
}
}
}
function lighton (){
if (lightingswitchScript.lighttouch == false){
on= true;
if (on == true){
light.intensity = 2;
}
else {
light.intensity =0;
on = false;
}
}
}
Any ideas are greatly appreciated.
NOTE: this is new code.
Pay attention: OnTriggerEnter needs at least one rigidbody among the two colliders. Is that the problem?
– BiGnope, player is a rigidbody, so it's fine i think!
– BobbleHeadIs your debug log "hit" showing?
– wccrawfordyep! but i'll alter the first post as changed the code methology
– BobbleHeadWatch out, you've written lightingswitchScript2.lighttouchh with double final "h"! I know that's not the main problem, but I'm just letting you know.
– BiG