Announcement

Collapse
No announcement yet.

[FEATURE REQUEST] Construction script for BP components

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

    [FEATURE REQUEST] Construction script for BP components

    Hi,

    Id like to procedurally add meshes in various blueprints.
    It would be cool to place that into a BP component so this ability could be added to various BPs.
    But for that BP components would need to have a construction script....

    Cheers,
    Klaus

    #2
    I put my construction script relevant stuff into its own function which I can then call either from the main construction script or even during runtime, if I need to

    In the same way I just call a construction function in my child blue prints

    Comment


      #3
      I put my construction script relevant stuff into its own function which I can then call either from the main construction script or even during runtime, if I need to
      In the same way I just call a construction function in my child blue prints
      Say, I have an array full of data and several functions that spawn meshes according to that data.
      Some BPs need that, some dont. But inheritance is not really feasible in this case.
      Id like to have that encapsulated together, so I can have several instances with different array values.
      Components would be ideal to give a BP this mesh spawn toolset, or not.

      But I just discovered that you cant even create static mesh components inside BP component functions, so I guess the component approach is dead anyway

      Comment


        #4
        well I have something working that does spawn instances of another blueprint (no inheritance) and of each instance of these I can assign different values and trigger different behaviors and such. Though I only advice doing that low frequency, e.g. during construction.

        Comment


          #5
          well I have something working that does spawn instances of another blueprint (no inheritance) and of each instance of these I can assign different values and trigger different behaviors and such. Though I only advice doing that low frequency, e.g. during construction.
          I always failed with that.
          In the construction script, I could set values for the spawned new BP actor, but it would not get applied.

          This is an older post aboout it. Maybe you can shed some light what is going wrong there?

          https://forums.unrealengine.com/show...hlight=fassade

          It would be really cool to solve this type of problem

          Comment


            #6
            Originally posted by KVogler View Post
            I always failed with that.
            In the construction script, I could set values for the spawned new BP actor, but it would not get applied.

            This is an older post aboout it. Maybe you can shed some light what is going wrong there?

            https://forums.unrealengine.com/show...hlight=fassade

            It would be really cool to solve this type of problem
            Gooooooooooood morning

            Have you been able to test the possible solution we discussed?

            For those who weren't in our Skype call:

            - YES, changing properties of a child BP does not trigger that child BP's Construction Script

            - the solution is to move the BP-implementation of your Construction Script to its own function and call that function from the CS as well as from the parent BP to update the thing

            Comment


              #7
              Hi,

              Just sent you a skype msg

              I recreated a simple example case, and its still not working
              If I call the building function of the child from within the parents constructor... nothing happens.

              Here is an overview:

              This is a simple BP that creates some meshes, based on an Instance and height offset parameter.
              The implementation happens in the BuildStuff function.

              Click image for larger version

Name:	SubConst.JPG
Views:	1
Size:	89.3 KB
ID:	1100710

              This is the BuildStuff function:

              Click image for larger version

Name:	SubBuild.JPG
Views:	1
Size:	73.4 KB
ID:	1100711

              If I place them in the level, they work like a charm, even at construction time:

              Click image for larger version

Name:	SubEditor.JPG
Views:	1
Size:	24.1 KB
ID:	1100712

              So, now I define a struct for some data for the "Master" BP:

              Click image for larger version

Name:	DataDef.JPG
Views:	1
Size:	34.6 KB
ID:	1100713

              And the Master BP also implements its stuff in a dedicated function, called BuildBPs:

              Click image for larger version

Name:	MasterConst.JPG
Views:	1
Size:	116.1 KB
ID:	1100714

              The implementation of BuildBPs spawns now the SubBPs and calls its BuildStuff function..

              Click image for larger version

Name:	MasterBuild.JPG
Views:	1
Size:	73.2 KB
ID:	1100715

              But in the editor, nothing is happening. Not at designtime, nor during gameplay of course..

              Click image for larger version

Name:	MasterEditor.JPG
Views:	1
Size:	126.2 KB
ID:	1100717

              BUT: If I hook up the BuildBPs function in the master BP begin play event, like so:

              Click image for larger version

Name:	MasterEvent.JPG
Views:	1
Size:	26.1 KB
ID:	1100718

              Then I get the spawning during gameplay:

              Click image for larger version

Name:	EventPlay.JPG
Views:	1
Size:	46.5 KB
ID:	1100719

              But this is not really usefull for a lot of reasons. I cant design a whole urban environment "into the blind" and only see during PIE where my buildings are....
              Since they are not spawned before BeginPlay, they cannot receive any lightmass attention. Hence the warning in the screenshot above...
              Plus a lot of warnings about it:

              Click image for larger version

Name:	errors.JPG
Views:	1
Size:	67.4 KB
ID:	1100720

              Of course. I set them to be static, but spawning at Begin Play just isnt....

              So even with the function being explicitly called... Nothing happens.
              If that would be fixed/possible, Blueprint would be a fully fledged "Prefab" system....

              Or am I still doing something stupendously wrong here

              Cheers,
              Klaus
              Last edited by KVogler; 02-17-2016, 04:12 PM.

              Comment


                #8
                thanks for the in-depth reply. As discussed in Skype we will continue adding a little code and then post the results here. I am confident that we can make it work - even if it means adding a little black magic

                Comment


                  #9
                  Whenever something isn't working as expected, check the output log tab first!
                  In this case, it will be telling you that you're not allowed to spawn new actors from within a construction script. I think this is an intentional limitation - it's one thing to keep track of what components were created procedurally and remove them when the script is rerun, but to try to have such dependencies between actors would likely get out of hand rather too quickly.

                  You should be able to achieve what you want, but you'll have to do it with components only, meaning you can only have one construction script driving the whole process.

                  Comment


                    #10
                    You should be able to achieve what you want, but you'll have to do it with components only, meaning you can only have one construction script driving the whole process.
                    The problem with that is that BP components cant create static mesh components. Just found out that the node is simply not available in components.

                    Comment


                      #11
                      Yep that's true, you'd have to do it all directly from the actor construction script.
                      I think your original request would be nice to have, was just pointing out what you can/can't do currently.

                      Comment


                        #12
                        Yep that's true, you'd have to do it all directly from the actor construction script.
                        So one is actually encouraged to abandon all OOP wisdom and create a monster class on purpose...
                        On the other hand. In my world outliner, I would only have one actor for the entire level geometry. However, this actor would then have thousands of functions and public variables.....

                        I think your original request would be nice to have, was just pointing out what you can/can't do currently.
                        Sure.
                        Lets hope Epic catches the drift

                        PS: And making it a single actor would also mean that if I change one value, the entire script is rerun...
                        That rules out the creation of large environments..

                        Comment


                          #13
                          Oh, and just for the sake of completeness: The macro approach is also not possible.

                          A macro like this:

                          Click image for larger version

Name:	macro.JPG
Views:	1
Size:	57.8 KB
ID:	1100782

                          produces this, when used:

                          Click image for larger version

Name:	macrouse.JPG
Views:	1
Size:	54.9 KB
ID:	1100783

                          It really seems to be impossible to add static meshes in any organized fashion.

                          Comment


                            #14
                            Can you use C++?

                            Why not write some helper methods (actually a Blueprint Function Library) which provides the functionality you want? For example, a static method which takes an actor and a static mesh and creates and attaches a static mesh component to that actor?

                            Comment


                              #15
                              Can you use C++?
                              Im not very good at C++ (still early learner), especially with the Unreal specifics of C++....

                              Comment

                              Working...
                              X