# Basic Lightswitch Problem

**URL:** <https://forums.unrealengine.com/t/basic-lightswitch-problem/38101>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [August 10, 2015, 10:54am UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101 "2015-08-10T10:54:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenMarriner3D](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benmarriner3d/32/762609_2.png) [@BenMarriner3D](https://forums.unrealengine.com/u/BenMarriner3D)\
**Post date:** [August 10, 2015, 10:54am UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/1 "2015-08-10T10:54:57Z")

</div>

Hello everyone,

I am having an issue creating a blueprint for a lightswitch to do a basic task of turning lights on and off when you press your use key and the thing is… It doesn’t work and I don’t know what I’ve done wrong or if I have forgotten to do anything.

I have attached some photos of all my blueprints that are being used in conjunction with the lightswitch blueprint.

![336e0945e2ed9e9c60c39d950a115a0ab0b43a7d.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

 ![Basic Lightswitch Problem Image 02.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/a/8a16383d9b7c3e3a3988a154083de1effaeae305.jpeg) ![a1bb5b016f610ac4e2314b2082ac88f5d17d29ac.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png) ![90a5d1f5ae91b249353427114a38ef72586c740d.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

Can somebody point out my mistake and tell me how fix it? I am relatively new to blueprint scripting,  
Goolog

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cb7e9863](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cb7e9863](https://forums.unrealengine.com/u/anonymous_user_cb7e9863)\
**Post date:** [August 10, 2015, 1:56pm UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/2 "2015-08-10T13:56:05Z")

</div>

Are you sure that the BluePrint is receiving the input key? Try use a “print string” just after events start (i mean, just after “interact” with them). If there is no text, it will mean that events never happen.

After you check it, the next step is check if it do something, whatever.

If you press Play and keep an eye in the code of your Blueprints, you can select a “Debug Filter” and see the how game is moving along all nodes. With that you can see if it enter in the code that Should enter.

---

<div class="post-metadata">

**Author:** ![BenMarriner3D](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benmarriner3d/32/762609_2.png) [@BenMarriner3D](https://forums.unrealengine.com/u/BenMarriner3D)\
**Post date:** [August 11, 2015, 10:17am UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/3 "2015-08-11T10:17:58Z")

</div>

The Cast To node in the lightswitch blueprint is what’s not working… I’ve tried a few methods and they don’t appear to work. I do not know what the object reference in the node means. Meanwhile I get a compile warning saying that ‘BP Ceiling Light’ does not inherit from ‘Static Mesh Component’ (Cast To BP\_CeilingLight would always fail). When a blueprint doesn’t inherit from something, I don’t know what it means.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cb7e9863](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cb7e9863](https://forums.unrealengine.com/u/anonymous_user_cb7e9863)\
**Post date:** [August 11, 2015, 10:50am UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/4 "2015-08-11T10:50:35Z")

</div>

Maybe you should start doing it step by step and keep if what you do work or not.

I mean, first try that a string happen in screen when you interact. When you do it, then next step should be switch on a single light, after switch on and off, later more lights, etc etc. I guess you get the point.

I am very novice too, so I could be wrong. Anyway I’ll say you what I see and what I try. Lets checks the pictures:

in your “BP\_Lights switch” blueprint you have a component (called “var lightswitch”, and if I am not wrong you created it dragging it from scene components to blueprint). It is ok, but in order to interact with a blueprint it’s object must be declarated as that blueprint (I mean, if you want interact with the blueprint called “BP\_Ceilling Light” you must create a variable declared as “BP\_Ceilling Light” type).

In your “BP\_ceilling light” blueprint you have a boolean variable that never change in code (and if I am not wrong, it should be set ON and OFF after the branch).

In your last image, “Player control”, I guess you tryed it already and saw it work. I really try and check this first, just change that “on interact” to a “print string” and see if you see the text.

---

<div class="post-metadata">

**Author:** ![\_cDub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_cDub](https://forums.unrealengine.com/u/_cDub)\
**Post date:** [August 11, 2015, 3:06pm UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/5 "2015-08-11T15:06:41Z")

</div>

This isn’t really a fix to your problem, but try this out in your construction script:

 ![lightswitch.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/3/e3641f4320e1a1bf30a2c3507bc9e69d77d8e445.png)

---

<div class="post-metadata">

**Author:** ![BenMarriner3D](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benmarriner3d/32/762609_2.png) [@BenMarriner3D](https://forums.unrealengine.com/u/BenMarriner3D)\
**Post date:** [August 11, 2015, 9:22pm UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/6 "2015-08-11T21:22:55Z")

</div>

I copied this out but some of the blueprint is still offscreen in the screenshot. Can you send me another plz?

---

<div class="post-metadata">

**Author:** ![BenMarriner3D](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benmarriner3d/32/762609_2.png) [@BenMarriner3D](https://forums.unrealengine.com/u/BenMarriner3D)\
**Post date:** [August 11, 2015, 9:32pm UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/7 "2015-08-11T21:32:56Z")

</div>

Actually, I tried it out, it adds point lights to the lightswitch itself then you gotta adjust the XYZ vectors to fit the exact location of the Ceiling Light itself… I want the lightswitch to be able to control the visibility of the pointlight that is located within the ceiling light blueprint.

---

<div class="post-metadata">

**Author:** ![pattym](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pattym](https://forums.unrealengine.com/u/pattym)\
**Post date:** [August 12, 2015, 1:00am UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/8 "2015-08-12T01:00:29Z")

</div>

This is a very simple setup for toggling a light on and off on a key press when inside a trigger box. You should be able to modify it to work from a line trace. This setup uses blueprint interfaces which I assume you understand along with how to correctly reference actors in the scene.

**Switch Blueprint:**  
 ![UE4_LightSwitch_01.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/a/a/aa54c5681b215fa4c211bb32be990f7a988d9b80.png)

**Light Blueprint:**  
 ![UE4_LightSwitch_01.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/4/4b446a8826a3ab8eeb3b789a6c0fe35af112c5aa.png)

---

<div class="post-metadata">

**Author:** ![\_cDub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_cDub](https://forums.unrealengine.com/u/_cDub)\
**Post date:** [August 12, 2015, 3:27am UTC](https://forums.unrealengine.com/t/basic-lightswitch-problem/38101/9 "2015-08-12T03:27:55Z")

</div>

> [@Goolog;353566](#):
>
> Actually, I tried it out, it adds point lights to the lightswitch itself then you gotta adjust the XYZ vectors to fit the exact location of the Ceiling Light itself… I want the lightswitch to be able to control the visibility of the pointlight that is located within the ceiling light blueprint.

Like I said, not a fix to your problem, but it is still pretty cool. If you check the show 3d widget on your transform array variable, you can drag the point lights around as if it was actually there.  
It lets you re use your light switch blueprint and not make a new bp to have more lights, or from having to get references to lights.
