I want to to make it so when you come up to the light switch a message is displayed in screen press o to turn on light and it causes that rooms light to turn on. Would some one please help me get the code set up I have never made a message popup and am not shure what the code to turn off and on a light is.
Thanks
At a high level, what you will want to do is to detect that your character is at the light switch. To do that, you can place a collision box in front of the light switch model/GameObject and flag it as a trigger. When the character enters the collision box, an OnTrigger event will be generated. This can be the indication that if the user now presses the “o” key, the light can be switched on or off. Next you will want to detect that the “o” key has been depressed. When this happens, that will be the indication to turn on/off the lights.
The Light object has a property called “enabled”. If this property is set to false, the light will not be part of the scene. You could toggle the light switch with:
myLight.enabled = !myLight.enabled