- Home /
PIckUp the flashlight
Hi, I was wondering how I could
1."Pick up" a flashlight when I run into it.
2.Toggle the light component of the flashlight on/off by keypress.
I have skimmed through many tutorials, but all of them are too much for me at the moment, I am new to coding, and don't need the whole battery drain thing. I just need somewhere to start.
Answer by clunk47 · Aug 16, 2013 at 05:03 PM
To toggle the flashlight, attach a script to the flashlight that accesses its light component.
if(Input.GetKeydown(KeyCode.F))
light.enabled = !light.enabled;
A simple pickup, you could use OnTriggerEnter, and use a boolean to determine whether or not you're holding it. Do your homework on the information I've provided and you'll be picking up flashlights and toggling them in no time :D
Converted your answer to comment. Please use the "Add new comment" when posting a comment to an answer.
Also tick the button to accept the answer, if you feel the question has been answered
@tone20, please accept and vote up the answer if it resolves your concern.