Announcement

Collapse
No announcement yet.

Blueprint Array related bugs (pin type detection error, get as reference, in struct array related)

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

    [BLUEPRINT] Blueprint Array related bugs (pin type detection error, get as reference, in struct array related)

    Related thread:
    https://forums.unrealengine.com/show...ments-directly

    Hi all,

    I tried to set values to an array in struct through a local reference(?) of the array.
    "Break Array" seems to return a ref of array, but only values in local one are changed.
    I guess "Set" function does not set a ref but makes a copy of array.



    ----
    It maybe better to separate the thread but I found another bug while testing array and structure related nodes.

    "Make Array" cannot detect pin types if
    1.Wildcard pin (like "Array length" input pin) is connected to "Make Array" output pin first
    2.Then connect integer pin (like "Make LiteralInt" output pin) to "Make Array" input pin

    This can be recovered easily but.. want to be fixed.
    1.Remove all links from Make Array node
    2.Connect input pin first.

    Thanks.

    #2
    Engine version: 4.15.1

    1.png: Test1_MakeArray
    This doesn't compile.
    Make array cannot detect pin types if wildcard array pin is connected first.
    Click image for larger version

Name:	1.png
Views:	1
Size:	82.2 KB
ID:	1126645

    2.png: Test2_Resize_GotArray
    Get array seems to return a copy of array, (not a ref)
    Click image for larger version

Name:	2.png
Views:	1
Size:	250.9 KB
ID:	1126646

    3.png: Test3_Resize_MadeArray
    Cannot resize an array made with Make Array.
    Click image for larger version

Name:	3.png
Views:	1
Size:	191.0 KB
ID:	1126647

    3-2.png: Test3_2_Resize_LocalValueArray
    Works correctly.
    Click image for larger version

Name:	3-2.png
Views:	1
Size:	231.9 KB
ID:	1126648

    4.png: Test4_Resize_InStructtArray
    Resize Arr_1
    Click image for larger version

Name:	4.png
Views:	1
Size:	247.7 KB
ID:	1126649

    4-2.png: Test4_2_Resize_InStructtArray
    Resize in struct array.
    Click image for larger version

Name:	4-2.png
Views:	1
Size:	246.8 KB
ID:	1126650

    5.png: Test5_SetArrayElem_to_Array_in_Struct
    Works correctly.
    Set Array Elem to the array which Break Array returned.
    Click image for larger version

Name:	5.png
Views:	1
Size:	345.1 KB
ID:	1126651

    5-2.png: Test5_2_SetArrayElem_to_Array_in_Struct
    Through temporal array.
    Set may be the cause.
    Click image for larger version

Name:	5-2.png
Views:	1
Size:	356.3 KB
ID:	1126652

    st_test_intarray.png: Definition of struct used in tests.
    Click image for larger version

Name:	st_test_intarray.PNG
Views:	1
Size:	30.6 KB
ID:	1126653

    log.png: Outputs.
    Click image for larger version

Name:	log.png
Views:	1
Size:	38.6 KB
ID:	1126654
    Last edited by Dev.TMG; 04-20-2017, 09:50 AM. Reason: Uploaded images (was uploaded to gist).

    Comment


      #3
      I've run into this problem a few times, as well.

      Seriously hoping that it will get a fix one day.

      Comment


        #4
        Originally posted by Dev.TMG View Post
        Related thread:
        https://forums.unrealengine.com/show...ments-directly

        Hi all,

        I tried to set values to an array in struct through a local reference(?) of the array.
        "Break Array" seems to return a ref of array, but only values in local one are changed.
        I guess "Set" function does not set a ref but makes a copy of array.



        This is intended behaviour. If you want to modify an array within another BP or in a function (via parameter), you should make the Array be a array of UClass instad of USTRUCT.
        Structs are always Copy-by-Value and thus you never edit the "real" struct but a copy of it when passed as a parameter.
        However a UClass Array does what you want.

        Comment


          #5
          How do you instantiate a UClass without a transform?

          Comment


            #6
            Derive from Object and not Actor.

            Comment


              #7
              Originally posted by Raildex_ View Post
              Structs are always Copy-by-Value and thus you never edit the "real" struct but a copy of it when passed as a parameter.
              So, what is "fixed" with UE-24080 mentioned in the thread I wrote as Related thread?

              Improve Get Array Item to return by-ref instead of by-value
              https://issues.unrealengine.com/issue/UE-24080

              Comment


                #8
                Originally posted by Dev.TMG View Post
                So, what is "fixed" with UE-24080 mentioned in the thread I wrote as Related thread?

                Improve Get Array Item to return by-ref instead of by-value
                https://issues.unrealengine.com/issue/UE-24080
                Well the thing is as someone mentioned above, is that Structs(USTRUCT) as far as the entire engine is concerned is almost-never passed around as a Reference, and rather is just passed by Value(Copys).
                This will work the way you want it to work if instead of Structs(USTRUCT), you change your data type to be a Class(UCLASS), because the engine always passes UClass's as pointers/reference.

                If you dont want to switch to UClass then the only other way to edit a Struct that you've added to an Array and have it be the one that resides in the Array, is to change it in C++ without the engines help(A.k.A without blueprints).

                Comment


                  #9
                  Originally posted by Diddykonga View Post
                  If you dont want to switch to UClass then the only other way to edit a Struct that you've added to an Array and have it be the one that resides in the Array, is to change it in C++ without the engines help(A.k.A without blueprints).
                  Nah, you don't need C++ for this. Here's one of the ways to do it in BPs:

                  Click image for larger version

Name:	Untitled.png
Views:	1
Size:	64.0 KB
ID:	1126472

                  Comment


                    #10
                    Originally posted by Everynone View Post
                    Here's one of the ways to do it in BPs:
                    Maybe Break struct (not ForEachLoop),
                    and set Array Elem is not needed for this, I think.
                    (As passing an array as ref, values in original array can be changed in Set members in CommonUniData.)
                    Or you meant array elements are structs? (If so, maybe affected by UE-6451.)

                    UE-6451
                    Set Members in Struct node doesn't work if the Struct is contained within an Array
                    https://issues.unrealengine.com/issue/UE-6451
                    (Target Fix: 4.16)

                    By the way, can we store a ref of array as a local variable?
                    Last edited by Dev.TMG; 04-20-2017, 10:14 AM.

                    Comment


                      #11
                      You can break the struct put it back together, plug it into the SetMembers node and it will work just fine. I only used ForEach node to indicate that it does, indeed, work with arrays just fine.
                      What is your actual issues? Consider posting it in the blueprints sections.

                      Comment

                      Working...
                      X