Hi Chris
I’ve added a toggle feature to turn the flashlight on and off for my main character, and I believe I set everything up correctly. However, when I run the game, nothing happens when I press the F key. I did debug the game and saw in the console that pressing F is detected.
Let me take you through my setup.
1) I created a Flashlight Object and attached Sprite light to it
https://prnt.sc/_bTC5JEKtNVr
2) Create a Global Variable (Adventure Creator → Game Editor → Variables Manager)
https://prnt.sc/igQqTB_61Nfk
3) Added Input in Unity: Name: FlashlightToggle
https://prnt.sc/aA8RAMjaDiEp
4) Then created Active Inputs in AC (same as Unity Input) and attached the ActionList to it
https://prnt.sc/SVtBZtxQDUB-
5) Created an ActionList for the Flashlight
https://prnt.sc/k-w_7JauSwkF
Any thoughts?
Thank you,
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Your Active Input's Input button needs to be set to FlashlightToggle - the name of the Input in the Input Manager, not the keyboard key it's ultimately mapped to.
Hi Chris,
Thank you for your reply. I've fixed the Active Input
https://prnt.sc/ZaUYYxlRBca9 and modified my Action script and used Object: Send Message https://prnt.sc/hEF5ckxwUfqF
However, I still can't toggle the flashlight.
Is the Variable value toggling in the Manager?
The "Turn Off" / "Turn On" commands won't work on Unity's built-in components - you need to attach a script that will be able to respond to those commands.
Try attaching this, setting "component" to the Light:
I’ve noticed that my character doesn’t interact with hotspots. Could this be an input issue affecting the flashlight toggle as well?
https://prnt.sc/Btx55TRF5qWC
https://prnt.sc/NcuW6BjxLaJ_
https://prnt.sc/X4KqzwHZ-A1f
How do I check if the Variable value is toggling in the Manager?
P.S. I fixed the Interaction issue but changing the Unity Input name from Submit to InteractionA
Yes, InteractionA is the input needed for Hotspot interactivity.
Variables values can be shown in the Variables Manager at runtime if Show realtime values? is checked.
I've checked the Variables Manager and can confirm that the values change between False and True when I press F. However, the Flashlight object remains on in the game. Why do you think the Flashlight object is not turning off?
https://prnt.sc/Bh2x4NJyfu46
You need to attach a script that can make use of the Turn On / Turn Off commands you're sending it - see the script I posted above.
Hi Chris,
I used the script you provided yesterday, but the issue persisted. However, I can confirm that the flashlight toggle issue is now working perfectly. I resolved the problem by deleting the character and all components related to the flashlight and then starting over. Although I’m not entirely sure what caused the initial issue, but deleting everything solved the problem. Here’s the final Action List and script for anyone looking to implement a flashlight.
https://prnt.sc/B1A8MAWTHeX2
https://prnt.sc/QN6WrXziMMqr
I appreciate your help, Chris.
Thanks,