Announcement

Collapse
No announcement yet.

Change visibility mesh object with button

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

    Change visibility mesh object with button

    Hey.

    What I want to do is have a button press change the visibility of a mesh object.

    I tried this:
    Created a Widget Blueprint with one button.
    Then I created this blueprint on the mesh I want to show/hide with the following nodes:
    Click image for larger version

Name:	1.JPG
Views:	1
Size:	51.7 KB
ID:	1144945
    Nothing

    Attempt number two,
    Click image for larger version

Name:	2.JPG
Views:	1
Size:	35.3 KB
ID:	1144946
    Same idea, this time in the Menu BP. Again nothing.

    Tried a lot of other things but no luck, hope someone can enlighten me!

    #2
    Still stuck unfortunately, how do I get a widget button to toggle the visibility of an object?
    I tried it with a light, the key press F works, the button still doesn't.
    Click image for larger version

Name:	3.JPG
Views:	1
Size:	32.6 KB
ID:	1067399

    Comment


      #3
      Starting to think it's not possible use input from a Widget Blueprint somewhere outside of that blueprint...
      Another weekend spend for nothing great !...

      Comment


        #4
        You will need to cast to that object, get mesh, then set visibility. That should work. I can make an example or show you an example from something I use later when I get back home.

        Coming 2016| Interested joining my team, email me: daniiartsstudio@gmail.com
        Official Thread! Unreal Forums Follow us on Facebook Watch development blog on Youtube

        Comment


          #5
          Thank you, will give that a shot when I get back from work !

          Comment


            #6
            Still no luck, I must be missing something but i'm doing the same things as the wiki explains.

            This is the blueprint of a wall mesh in the level, as a test I just want to print some text on the screen if it detects the button clicked
            Click image for larger version

Name:	4.JPG
Views:	1
Size:	27.8 KB
ID:	1067488

            This is button graph in the widget blueprint
            Click image for larger version

Name:	5.JPG
Views:	1
Size:	24.9 KB
ID:	1067489

            Nope

            Comment


              #7
              Just at a glance, you need to make sure to check the box next to "Klik" on your Set Klik boolean node after the cast node in your second screenshot. Right now the boolean is getting set to "false" on click, so even if everything else is set up correctly, the event tick is going to travel down the "False" half of your branch in the first screenshot.

              Comment


                #8
                Thanks will give it a shot later, don't think thats the only issue. When I run the level with logging on I see the "cast to muur_blueprint" fail for some reason.

                Comment


                  #9
                  It will fail, you have no reference of an object going into the cast...

                  What are you trying to achieve? Looking at something, clicking and making it disappear? If so you could raytrace to it and on the hit output is equal to what you want, going into a branch which then casts to the class that has the kik thing in, set to true (ticked).

                  Comment


                    #10
                    Originally posted by jestersheepy View Post
                    It will fail, you have no reference of an object going into the cast...

                    What are you trying to achieve? Looking at something, clicking and making it disappear? If so you could raytrace to it and on the hit output is equal to what you want, going into a branch which then casts to the class that has the kik thing in, set to true (ticked).
                    I want a button (from the widget blueprint) to toggle the visibility of an object.

                    The reference part I don't really get , I've tried to create a var. from a scene object and wired that into the Cast To Object slot but no luck so far.
                    What is confusing to me is why it needs a reference in the first place. The blueprint I cast to is from a mesh object already.

                    Comment


                      #11
                      Click image for larger version

Name:	6.JPG
Views:	1
Size:	31.7 KB
ID:	1067579

                      Add a var with the blueprint i'm casting to
                      Click image for larger version

Name:	7.JPG
Views:	1
Size:	39.1 KB
ID:	1067580
                      nope

                      Comment


                        #12
                        Hi Cultor,
                        I have the same problem "Change visibility mesh object with Widget button" 14 days and still nothing , I do not understand it If you come up with something, I would be really helpful.

                        Comment


                          #13
                          Hello,
                          Instead of a reference, which need to be set with the specific actor in the level you want to interact with. (On event begin play for example), do a "get all actors" selecting your blueprint in "actor class". If you have only one actor of this class, drag a "get" from it and drag your bool from it (don't forget to check your bool) If you have more than one actor, you will need to use a tag to know which actor activate : https://docs.unrealengine.com/latest...nts/index.html

                          Comment


                            #14
                            I double post to show you the 2 possibilities :
                            1 in level blueprint : You create your widget and you immediatly "set" your reference with the blueprint ( selected in level and right click to have it in level blueprint) then in widget, you use the reference filld and drag your mesh (cube in my example) to set its visibility. (i used a custom event named "event click" but this is the click button event as the one under)

                            2 in widget only : You get all actors of this type of blueprint and get it (because there is only one. if there was more, i would have do a for each loop and cehck the one i want to use)

                            Click image for larger version

Name:	clickmesh.jpg
Views:	1
Size:	119.1 KB
ID:	1067591

                            Comment


                              #15
                              In order for any blueprint (other than the currently possessed pawn) to receive input, you must first turn that on:

                              Click image for larger version

Name:	Input.jpg
Views:	1
Size:	100.3 KB
ID:	1067593

                              Without this, no input events or functions (for example: on button press) will work.

                              I think this might be your problem.

                              Comment

                              Working...
                              X