Good afternoon everyone, in FirstPersonCharcter, I have the Spot Light component attached to the camera component, when the game starts, the Spot Light glows. Spot Light is a component for a flashlight, when you press the F key, the flashlight turns on, how to make the Spot Light not shine all the time, it turns out that the character’s hands light up, I don’t understand how to turn off the Spot Light glow in the game, only to make the glow be called by pressing the F key ?
how to make the Spot Light not shine all the time […] I don’t understand how to turn off the Spot Light glow in the game, only to make the glow be called by pressing the F key ?
Start with the component not being visible and then:
it turns out that the character’s hands light up
- either place it in front of the hands - the most convenient
- or you can try using channels:
If the light is on channel 0, meshes that ignore channel 0 will not be lit. But then you’ll need to consider how other lights behave as well.
Thank you very much for your help. It helped by switching channels Channel 0 to Channel 1, I tried to uncheck the Visible In Game, the light does not appear even when the F key is pressed. to the Lantern Mesh. The path is a light on a weapon or a light on a helmet or on any other moving light source.
It seems you did it the other way round. If you switch the channel on the light, you’ll need to tell every mesh in the game to take it into consideration. You can read up on this feature here:
Honestly, consider placing the light in front of the player.
Yes, I understand you that you will have to set Channel 1 for all light sources. I left the checkboxes as they are by default at Rendering> Visible to true and also in Lighting Channel 0 there is a checkmark. I understand that in Channel you can change, for example, RGB light channels for Channel light sources.
I didn’t quite understand how to completely remove the light so that Spot Light only shines when you type from the keyboard to the F key. In games that use a flashlight, I also noticed that the light is present even when the flashlight is not shining, until I know how to fix this bug.
If you remove the Checkbox, then the flashlight does not work when you press the F key. But the light in the scene disappears.
Could you please show the script used for this.
Direct link to your vid (extracted your channel from the link and found the vid uploaded recently):
You’re showing too much script, let’s isolate and get this going in a simple way and then you can plug it into the rest of your logic.
For example:
You’re using Hidden
not Visibility
- they’re different!
If you mix the two up, you will need to handle it differently.
Try it the way I suggested, get it to work in the most basic way and only then incorporate
I did as you said, pulled a wire from the Spot Light and selected Set Visibility, put a checkbox next to the New Visibility of the Set Visibility node. I started the game, the light disappeared, I pressed the F key once, the flashlight turned on, I pressed the flashlight light again, I press F again, the light from the flashlight does not appear a second time.
Also removed checkbox from Visible.
In your vid you were using a different node. You need to decide which one you want to use. If you Hide
something in game, Visibility cannot show it… because it’s, well, hidden.
This is caused by the rest of your script not set up correctly. Please test it the way I suggested, for now. Later on you can work on the other logic.
I solved the issue, thanks I replaced the nodes and turned off the flashlight. Thank you very much for your help in helping me figure out the nodes. Now the light from the flashlight works when you press the F key, when you release the light disappears, and when you press F again, the light appears.