I’m trying to get a light switch on the wall to activate a light on the ceiling using line trace and i don’t understand how to make this work.
i’ve managed to make the blueprint for the line trace, but beyond that i don’t know how to make it interact with the switch mesh. should i make a blueprint for that mesh and have it interact with the light on the map? can that be done cause i can’t seem to do it. or do i need to put the light inside the blueprint? i don’t know. i’m completely in the dark here and tutorials i’ve seen aren’t helping. i’m completely new to this and i haven’t looked at a blueprint until a few days ago.
this is where i’m at right now. did the line trace on the character BP up to here, but i don’t know what to do from this point on and i’ve been trying for some days now (line trace is working fine so far btw, i can see the red beams in debugging)
When you trace the switch, you could make a branch checking for if the actor you hit is the switch (you might run a print to screen to get the exact actor name). When the bracnh is true you should get the blueprint in which your light is, and turn the light on, in how you seem fit.
you’re assuming i understand blueprints. i don’t. like i said i only started looking into those a few days ago. i don’t know what to do to make the trace interact with a light. how should i make the blueprint for the light and how should i connect the trace line with that blueprint. that’s what i need to know. could someone please post an example i can download and reverse engineer maybe?
Make two blueprints. One for your lightswitch and another for your light.
Make a variable that is the same type as the light blueprint.
Make a function on your light blueprint that will adjust the light component’s intensity.
After you compile and save go to your level and select your blueprint. On the window with the blueprint details you will find that light blueprint variable, use that to select what lamp you want to turn on and off.
Make a function on your lightswitch that will take your light variable and call that intensity changing function
Line trace and break the result. Take the traced actor and cast it to your lightswitch.
Use the “As my” and call that function on the lightswitch.
I am away from my computer for the next few days so I can’t give you a screen shot, but hopefully this breaks it down for you a bit.
i really can’t get this. there are literally infinite combinations when i don’t know where what goes where or what goes with to make this work. i’m going to need a visual representiation in order to get this and make it work. i’m really frustrated with this
Yeah you need to do some tutorials for how to set this up. People can’t just build the exact project that you want for you… unless you want to pay them to do so. People are happy to help with advise but you are asking for a step by step exact replication of what you want. I could do it for sure, but not everybody is going to take their time to make a very specific tutorial in a very short time frame for no reason other than you want it because you are too lazy to learn on your own
so i managed to turn the light off the light but can’t turn it back on again. i think i need to do a check if light is on first but i don’t know were to put that or what the command for it is
here’s what i have so far
Never mind i got it. I changed set intensity to toggle visibility on the light and seems to be working. Thanks! That video really helped me to understand this system.
The Boolean return value on the line trace will tell you if it hit something. That is why it didn’t turn off before. That branch could be false and hit something at the same time. And nice work.
it didn’t turn off before because i was using intensity and didn’t know how to set it up properly. it’s easier and simpler to use toggle visibility and works exactly like i wanted.
didn’t need to use booleans (don’t even know what that is exactly yet). but for now this worked out well enough for what i wanted so far. still getting around to understanding blueprints.
To anyone novice like myself who stumbles uppon this thread and has the same questions i had about interacting with a button in order to turn off a light somewhere on the map this is how i solved it:
make a blueprint interface just like in the video. just create a new one and rename the action to Looking at or something. don’t need to mess with it any more than that for this
make blueprints of the light and the button mesh you want to use
on the light blueprint all you need to do is select the light, right click and search for toggle visibility. just that, no event needed on the light if you don’t want to interact with it directly
on the button blueprint start by adding the Looking At event like it shows on the video, then Get All Actors of Class, select the light blueprint you want to turn on/off, select ForEachLoop and call Toggle Visibility function