Hi all, I’m trying to figure out Casting in blueprint. Like you can see in my screenshots, I have a blueprint with a spotlight and I want to turn on/off the light with a button in the widget. The problem is if I try to do it with cast inside the widget event graph, it doesn’t store the value of the visibility of light, so if I start my project with light off and I call the widget - turn on the light with button - close widget - open again widget, I have to click two times the button to turn the light off. Instead I put a custom event in the light Bp and in the widget bp I attach to the button un get all actors of class and call the custom event in the bp, it works. I don’t know if I explained myself well, but I hope you can understand me and help me. I’m sorry for my bad English.
( and set the light intensity in the BP to zero by default )
Thank you for your answer. Yes I know, in this way it works, but I would do it cast it in the widget bp.
Why do you want to cast? The blue line under your cast means it’s doing nothing…
To learn a new method to do it. It works if I do in that way, but when I call again the widget it’s like it restart is parameter exept for the visibility of light that works fine.
Ok, your code is back to front. The stuff for controlling the light should be IN the light BP, not in the widget The light already knows if it’s on or off, that’s why it’s good to put the code for the light IN the light.
The cast is not doing anything.
The light BP is creating the widget, level BP would be a better place to put the W event. Also, you check if the widget exists, and then create it anyway.
Thank you for your reply and disponibility. I don’t know how, but with your words you let me reach the solution. I understood what you told me but in anyway I managed to make it work. The solution is on the screenshots. I don’t know if it’s a good way but now it works. In this way the widget knows if the light is on or off. I was wrong about the variable to attach to the branch,
but thanks to “The light already knows if it’s on or off” I find the solution. Thank you!