Light follow my character?

Hello!
I want to make a script; when my character enter trigger box - light start follow you ( like a flashlight turn on).
How can I make it?

details bro, you need to provide more in your questions. does the light already exist? is it like a spotlight? if its like a flashlight where is the light coming from? theres many things you didnt mention so we are left to wonder.

this is probably a wrong assumption, but assuming its a spotlight and it doesnt already exist in the world then you would just need: on actor begin overlap → spawn actor from class Spotlight (location: player location +300Z) → attach to player character.

Yes. Like a flash light. The light doest exist yet. I want the game to make a light source attached to the character when I trigger the box (overlaping)
it is like to turn on a flashlight without pusing down the key, But overlaping the triger box.

I tried as You said. Light source bean spawned But it is not attache to my characte…

I just want to make certain area around the character vissible in the dark

What @ said. Just spawn a light actor you can use “attach to actor” and place it wherever you want. Not hard to do at all.

theres basically two ways to go about this, you can either create a new light or have a light setup in the character and toggle its visibility.

the first picture below shows the first method of creating light, settings its location, and attaching to the character. the script i setup here creates the light when you enter the volume then if you enter it again it destroys the light. a simple on off kind of thing.

the second picture shows the second method mentioned where the light is added to the character beforehand then you just toggle its visibility. this is a much simpler script to write and setup but has its limitations since it needs to be setup beforehand.

It’s different from what the other guys here have recommended, and I don’t know if it’s the best practice way to do it, but I was able to achieve what it sounds like you’re trying to do with the following:

  1. In the Blueprint for your character, add whatever kind of light component you’re wanting to have appear and position it where you’d like it to be relative to the character. You’ll probably want to test that in gameplay first and make sure it looks the way you want it. That includes playing with the intensity setting in the details panel to figure out how bright you want it to be (remember that, it’ll matter in a minute)

  2. With the light selected in the components panel, go over to the details panel and set the intensity for the light to zero. Then, in your event graph, create a custom event (if you don’t know how, just right click, then type “cust” and the option will appear). Select that and name the event what you like. Drag off the right and type in “set intensity.” Should see the option come up with the light you created named in parentheses. Select that. Inside the function, next to “new intensity” enter the value for the brightness of the light you decided on earlier. Compile and save.

  3. Create your trigger in the game world if you haven’t already. Select it and over in the details panel go to “edit blueprint.” Enter a name for the BP and save it wherever you like. With that done, on the event graph delete everything but the ActorBeginOverlap executable. Drag off it and type in “valid.” Scroll all the way down for the
    “? IsValid” option and select it. Drag off the right of the “Is Valid” output and just release. When the search box comes up, uncheck the “context sensitive” box in the upper-right. Then in the search bar enter the name of the custom event you created for the character and an option should come up for it. Select that.

  4. The two functions you made are going to need to know what BP they’re interacting with, so go over to the variables section of the “my blueprint” panel (you should still be inside the BP for your trigger). Select the button in the upper-right to make a new one. Name it whatever you want. Back over in the details panel, you’ll see an option for variable type. Select this and start typing in “first-person character” or whatever the character type for the game is. You’ll see its name pop up. Mouse over it, then “object reference” and select that. Directly underneath that section, check Instance Editable. That’ll be important in a minute. For now, back over in the variables section hold Control and drag off the variable you just made into the event graph. Connect that to your “input object” and “target” pins on your nodes in the graph (the single reference you made will connect to both). Compile and save.

  5. Go back to your world view and make sure you have your trigger actor selected. Over in the details panel, under “default” you should see the name of the variable you made, and
    next to it a drop down box (this was why you checked “instance editable” earlier, or you wouldn’t see that). Select that, and you should see the name for your character’s BP. Select it.

You should be finished. When you start play, the light is technically part of your character, but not on. When you overlap your trigger, it’s going to activate your custom event on your character and turn the light on for you, then since it’s a part of the character it will follow you from there. If you have any issues with this still let me know and I’ll try to help. Sorry for the lengthy reply but wanted to be as specific as possible to make it easy for you. Hope it helps. Cheers.

Thanks! You helped a lot.
I will use second variation.

Thank you for this valuable information. I will definetly practice it!

You’re welcome