FlashLight Problem

I made a flashlight in blueprint, In my character blueprint and it works fine. But what im trying to do is to have a part on my HUD Say "Flashlight: " Then if the flashlight is turned on it says On next to Flashlight: and if it is turned off it says off. Does Anyone know how i can achieve this? I have tryed everything i could thing of but have not had any luck, ill post screenshots of what i have right now.

Flashlight HUD


Flashlight Toggle

FlashLight Toggle.png

Flashlight ingame

Flashlight Ingame.png

in your first pic, your branch is always true.

you should, however, doing this.

  1. in your pawn, toggle on/off and then set a bool variable to true or false.

  2. in your HUD, get controller and then get owned pawn, then get the bool and use that to drive branch condition.

Ok im a little confused on what you want me to do for number one. But i tryed it and this is how i added it.





I’m pretty sure i did not do it right because it still does not work. :confused: Can you please explain a little bit more?

Firezown, I know you might already trying hard enough, and really tempted to just give you the answer you wanted.
But it feel that much sweeter when you learn it from a hint and realize how stuff works.

To be honest, you have to go through some basic tutorials, because from your graph it was obvious that you don’t know how to create and set a variable properly, you don’t know how to use a branch node.
Please refer to these links and make sure you understand how to use variable and nodes.

use key stroke and print to verify they work as intended, and your flashlight problem will be really easy to do.

i made the variable in my pawn. Now i need to get it into my HUD blueprint thats the part i cannot figure out. Those tutorials said something about refrences but that just adds it to the defaults. How can i get my HUD blueprint to Recognize the variable made in my Pawn blueprint?

I think you mean you need to access the variable in HUD and display some text accordingly, right?
It works the same as in the tutorial below, except you want to be casting to your character/flashlight blueprint, from your HUD. (about 2:30 into the video. Watch the entire thing though. It might help you clean up some existing blueprints)

Ok, What i means is. I Have my flashlight graph setup inside mycharacter.(First picture below) And what is does is when i left click it turns the spotlight on or off. What i am trying to do is, At the same time have text display on the screen. So for example, When you load the level the flashlight is on. So when the flashlight is on i want it to say “Flashlight: On” on the bottom left of the screen. Then when you button again the flashlight turns off. And it says “Flashlight: Off”. That’s what im trying to do right now, I have all the draw text and things setup, But what i need is to know how to somehow get the information from the pawn so the HUD knows when the flashlight on or off.

But i did not really see anything in that video that does anything like that. And im not sure how to get this done ;/

Yes. That’s what I thought.
Here is a basic way of doing it. I have not included any light controls on the character blueprint, but this shows the toggle and the checking/drawing of the variable in your HUD.
Please note, my examples are completely untested, so I might have made a mistake. I just threw together the nodes to show you how it should be layed-out.

You need to understand how casting between blueprints works, as well as the fundamentals of computing logic. Follow the tutorials on the Unreal Engine Youtube channel. They might help you implement things you are trying to do a little better.

For some reason my HUD does not give the option for cast.

i thought using a interface blueprint would work but it did not help. I cannot seem to figure this out.