Announcement

Collapse
No announcement yet.

Basic Lightswitch Problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Basic Lightswitch Problem

    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.

    Click image for larger version

Name:	Basic Lightswitch Problem Image 01.jpg
Views:	1
Size:	210.9 KB
ID:	1159141 Click image for larger version

Name:	Basic Lightswitch Problem Image 02.jpg
Views:	1
Size:	349.9 KB
ID:	1159142 Click image for larger version

Name:	Basic Lightswitch Problem Image 03.jpg
Views:	1
Size:	463.7 KB
ID:	1159143 Click image for larger version

Name:	Basic Lightswitch Problem Image 04.jpg
Views:	1
Size:	479.3 KB
ID:	1159144

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

    #2
    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.

    Comment


      #3
      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.

      Comment


        #4
        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.
        Last edited by vegetamaker; 08-11-2015, 06:54 AM.

        Comment


          #5
          This isn't really a fix to your problem, but try this out in your construction script: Click image for larger version

Name:	lightswitch.png
Views:	1
Size:	221.0 KB
ID:	1083612

          Comment


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

            Comment


              #7
              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.

              Comment


                #8
                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:
                Click image for larger version

Name:	UE4_LightSwitch_01.png
Views:	1
Size:	91.9 KB
ID:	1083644

                Light Blueprint:
                Click image for larger version

Name:	UE4_LightSwitch_02.png
Views:	1
Size:	52.6 KB
ID:	1083645
                Check out my pet project: Salvos - Maze Survival

                Looking for blueprint tutorials? Then visit my blog or YouTube channel.
                Blog: voxagon Youtube: Click

                Comment


                  #9
                  Originally posted by Goolog View Post
                  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.

                  Comment

                  Working...
                  X