Announcement

Collapse
No announcement yet.

What´s the best way to toggle visibility for many object on/off via blueprint in gamemode?

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

    What´s the best way to toggle visibility for many object on/off via blueprint in gamemode?

    Hi,
    i am new to this forum, searched and learned a lot from it. But now i come to a point where good help is needed from you.
    Let´s say i imported 100 decor things in unreal and want to toggle it on and off with just a click of a keyboard or gamepad. What i learned now is, it can be done
    in a blueprint with all separate meshes added in it and then build the logic with visibility on and off (like in the pic below). So far so good.
    But, is there no efficient way to toggle on a group or a layer of objects at once?

    I thought when i have layers or make a group of objects in the editor with all the 100 of decor things in it, i can then call it in the blueprint and turn off on like the separate meshes.
    But i can´t find a way to do so. I don´t know how to add this named group or layer to the blueprint.

    Does anyone know the solution or can point me in the right direction?
    Thank you so much for your time

    Martin.
    KreatiVR:Interactive architecture visualization in 360° VR

    Follow me on:

    youtube:
    https://www.youtube.com/channel/UCi4...0nondmottOLAuw
    linkedIn: https://www.linkedin.com/in/martin-kogoy-99401a140/

    #2
    Tag all your decor actors with the same tag, say "decor". Use Get All Actors with Tag to get an array of them. Do a For Each on thr array and toggle visibility on/off for each element in the array.
    CTO | Head of VR Development - Visit us at http://humanxr.com
    My UE4 Tutorials (mostly VR): https://goo.gl/GUvDyV

    Comment


      #3
      Originally posted by vr_marco View Post
      Tag all your decor actors with the same tag, say "decor". Use Get All Actors with Tag to get an array of them. Do a For Each on thr array and toggle visibility on/off for each element in the array.
      Hi Marco,
      and thanx for your help. But something i didn´t get right. I insert the key press, then the "get all actors with Tag" and put in the word "Lamp". You wrote, i have to do a "for each..." after this?
      What kind of For Each...., there are so many.. ;-) ForEach loop? ForEach key pressed?... Hm.. And what is the next step then to toggle visibility on/off.. To connect it to my blueprint as in the picture, doesn´t work. Can´t connect the Out Actors of the "get all actors with Tag" directly to the "set visibility". I am a little bit lost, but i feel that we are very close to the solution for this.. I do something wrong or don´t even know it.

      Click image for larger version  Name:	Blueprint.PNG Views:	1 Size:	314.5 KB ID:	1532479

      Thank you.
      Martin.
      Last edited by KreatiVR; 09-26-2018, 07:42 AM.
      KreatiVR:Interactive architecture visualization in 360° VR

      Follow me on:

      youtube:
      https://www.youtube.com/channel/UCi4...0nondmottOLAuw
      linkedIn: https://www.linkedin.com/in/martin-kogoy-99401a140/

      Comment


        #4
        The ForEach is a loop on each element of the array produced by Get All Actors With Tag. If you drag out of the array output of the function the context system will recommend the right one for you. Then to Loop Body you connect a Toggle Visibility node and pass the current actor through a Get(Array Index).

        So:
        - On a key press, say T
        - Get All Actors with Tag "Decor"
        - ForEach loop on the array of actors with tag "Decor"
        - Toggle visibility of the current actor in the loop

        CTO | Head of VR Development - Visit us at http://humanxr.com
        My UE4 Tutorials (mostly VR): https://goo.gl/GUvDyV

        Comment


          #5
          Originally posted by vr_marco View Post
          The ForEach is a loop on each element of the array produced by Get All Actors With Tag. If you drag out of the array output of the function the context system will recommend the right one for you. Then to Loop Body you connect a Toggle Visibility node and pass the current actor through a Get(Array Index).

          So:
          - On a key press, say T
          - Get All Actors with Tag "Decor"
          - ForEach loop on the array of actors with tag "Decor"
          - Toggle visibility of the current actor in the loop
          Hey again.
          Have you seen my included picture of my blueprint? Is this completely wrong and what is the thing i did wrong. Remember i am not a specialist, only at a beginner stage with blueprints. ;-)
          Thanx again for your time to look at.
          KreatiVR:Interactive architecture visualization in 360° VR

          Follow me on:

          youtube:
          https://www.youtube.com/channel/UCi4...0nondmottOLAuw
          linkedIn: https://www.linkedin.com/in/martin-kogoy-99401a140/

          Comment


            #6
            Originally posted by mk010769 View Post

            Hey again.
            Have you seen my included picture of my blueprint? Is this completely wrong and what is the thing i did wrong. Remember i am not a specialist, only at a beginner stage with blueprints. ;-)
            Thanx again for your time to look at.
            - You have to run this in the Level Blueprint.
            - In the loop body, you don't need to check for the tag again, all the actors in the array you are looping on will have that tag because this is what Get All Actors with Tag returns.
            - Get the Array Element from the loop and call Toggle Visibility on it.
            CTO | Head of VR Development - Visit us at http://humanxr.com
            My UE4 Tutorials (mostly VR): https://goo.gl/GUvDyV

            Comment


              #7
              Originally posted by vr_marco View Post

              - You have to run this in the Level Blueprint.
              - In the loop body, you don't need to check for the tag again, all the actors in the array you are looping on will have that tag because this is what Get All Actors with Tag returns.
              - Get the Array Element from the loop and call Toggle Visibility on it.

              Ok, new try then.

              I got my blueprint under level blueprint now. This is how it looks now:

              Click image for larger version

Name:	Blueprint.PNG
Views:	2006
Size:	252.0 KB
ID:	1532508
              If i press 4 then, some meshes get on and the others go off in toggle.. why is this happening now?
              All have the tag "Lamp" on it. They have an actor as a parent in the editor because it is imported via datasmith.
              They share the same static mesh, as they are instances as far as i can read it right in the editor. Is there a problem because of that?
              Does it only works, when the meshes are stand-alone static meshes and no parent objects for them?

              Hm... a lot of things to do and know..
              Can you help about this? Is my blueprint alright now?

              Martin.
              KreatiVR:Interactive architecture visualization in 360° VR

              Follow me on:

              youtube:
              https://www.youtube.com/channel/UCi4...0nondmottOLAuw
              linkedIn: https://www.linkedin.com/in/martin-kogoy-99401a140/

              Comment


                #8
                That's what toggle does. What is off gets turned on and what is on gets turned off. If you want to turn them all on or off you have to use Set Visibility with the proper Boolean value.
                CTO | Head of VR Development - Visit us at http://humanxr.com
                My UE4 Tutorials (mostly VR): https://goo.gl/GUvDyV

                Comment


                  #9
                  Originally posted by vr_marco View Post
                  That's what toggle does. What is off gets turned on and what is on gets turned off. If you want to turn them all on or off you have to use Set Visibility with the proper Boolean value.
                  yes that´s what i thought about the toggle, which is what i want. But why is not turning on all meshes with tag at the same time when press the key? It look like it is limited to a few objects
                  and then at the next press of the key it toggle the other ones. Beware that all the objects are labeled with the same tag, in my case "Lamp". Any idea where this comes from?
                  KreatiVR:Interactive architecture visualization in 360° VR

                  Follow me on:

                  youtube:
                  https://www.youtube.com/channel/UCi4...0nondmottOLAuw
                  linkedIn: https://www.linkedin.com/in/martin-kogoy-99401a140/

                  Comment


                    #10
                    I don't know for sure since I haven't seen your project, but I am sure there is a reason. Is everything on the same level? Do you have streaming levels?
                    CTO | Head of VR Development - Visit us at http://humanxr.com
                    My UE4 Tutorials (mostly VR): https://goo.gl/GUvDyV

                    Comment


                      #11
                      Originally posted by vr_marco View Post
                      I don't know for sure since I haven't seen your project, but I am sure there is a reason. Is everything on the same level? Do you have streaming levels?
                      no streaming levels and all is on the same level. hm.. i will look into this further.. thanx so much for your help. at least i can now switch on instances of meshes to save resources.
                      have to find a way, so that they don´t show in the beginning of the level. i only want a clear building without furniture or deco and so on. then klick by klick you filling the room.

                      KreatiVR:Interactive architecture visualization in 360° VR

                      Follow me on:

                      youtube:
                      https://www.youtube.com/channel/UCi4...0nondmottOLAuw
                      linkedIn: https://www.linkedin.com/in/martin-kogoy-99401a140/

                      Comment


                        #12
                        Originally posted by mk010769 View Post

                        no streaming levels and all is on the same level. hm.. i will look into this further.. thanx so much for your help. at least i can now switch on instances of meshes to save resources.
                        have to find a way, so that they don´t show in the beginning of the level. i only want a clear building without furniture or deco and so on. then klick by klick you filling the room.
                        oh god, now i know what went wrong.. mixed the component tag with the actor tag ! so stupid that the component tag is more visible than the actor tag.
                        Now everything went fine and i can redo my blueprint.

                        Thanx a lot vr_marco you are an expert and i will become one in some days, weeks and month. ;-)
                        KreatiVR:Interactive architecture visualization in 360° VR

                        Follow me on:

                        youtube:
                        https://www.youtube.com/channel/UCi4...0nondmottOLAuw
                        linkedIn: https://www.linkedin.com/in/martin-kogoy-99401a140/

                        Comment


                          #13
                          Originally posted by mk010769 View Post

                          oh god, now i know what went wrong.. mixed the component tag with the actor tag ! so stupid that the component tag is more visible than the actor tag.
                          Now everything went fine and i can redo my blueprint.

                          Thanx a lot vr_marco you are an expert and i will become one in some days, weeks and month. ;-)
                          Glad you spotted your issue.
                          CTO | Head of VR Development - Visit us at http://humanxr.com
                          My UE4 Tutorials (mostly VR): https://goo.gl/GUvDyV

                          Comment

                          Working...
                          X