Hey guys,
I am new to programming with JavaScript and I was wondering how you would be able to print text to the screen(whether it be GUI based or what ever) on Key-pressing.
For example, I have this code here for a simple flashlight that allows the player to enable/disable a light (that acts as a flashlight) but what I want to know how to do is make it so that when the player presses the key and enables/disables the light, it relays a message back to the player on their screen whether they turned on the flashlight or turned it off. I know this would be really simple, but I’m trying to learn how to do it and examples would be very helpful for me.
Here is the script:
function Update(){
if (Input.GetKeyDown("f")) {
if(light.enabled == true)
light.enabled = false;
else
light.enabled = true;
}
}
Thanks.