I have a flashlight blueprint that contains a light source with an intensity variable. I added the flashlight blueprint to the first-person character by dragging the flashlight blueprint into the character blueprint viewport.
The flashlight blueprint follows this scheme (with auto receive input set to player 0).
While the flashlight dragged into the world reacts to button presses, the flashlight on the character does not.
So, I think I should manipulate the character’s flashlight directly. To do this, I need to somehow get access to the character’s flashlight intensity in the character blueprint. How can I achieve this, or is there another solution?"
To add the flashlight to a character in Unreal Engine, you can follow these steps:
Create an Actor Component for Flashlight Control:
Create a new Blueprint class based on ActorComponent. Let’s call it FlashlightComponent.
Add a variable to store the Flashlight Actor.
Attach Flashlight to Character Blueprint:
Open your Character Blueprint.
Add a new component of type FlashlightComponent to your character.
In the Construction Script or Begin Play event of the Character Blueprint, spawn the Flashlight Actor and set it as the FlashlightComponent’s Flashlight Actor variable.
Control Flashlight State:
Add input events in your Character Blueprint to toggle the flashlight on/off.
In response to these input events, call functions in your FlashlightComponent to turn the flashlight on/off.