Announcement

Collapse
No announcement yet.

Struct not updating values?

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

    #16
    Originally posted by Everynone View Post
    That's not even a workaround, tbh, that's how things are.

    Hope it helps.
    This is a mega necro bump, but this was the most concise result about this problem on Google. I came here because I had this problem today, on v4.20.1

    I have an alternative that I thought I'd share.

    Instead of using Structs, which it looks like aren't objects and therefore can't be passed around like objects - Use a class. In C# Unity I would do this all the time for storing data.

    How to implement it in Unreal
    1. Make a new Blueprint of type Object, this becomes the data type.
    2. Add the variables you want to hold your data. I made a helper function to set both vars at once.

    Click image for larger version  Name:	Unreal1.JPG Views:	2 Size:	68.7 KB ID:	1533088
    3. When you want to use it in another blueprint, add a variable of that type (it can be an array just fine if you want)
    4. When you want to add to this array, the one thing you do have to do is Create the Object like so:
    Click image for larger version  Name:	unreal2.JPG Views:	1 Size:	85.9 KB ID:	1533086

    5. What's great is that it is really easy to get the variable data
    Click image for larger version  Name:	unreal3.JPG Views:	1 Size:	70.1 KB ID:	1533089
    Attached Files

    Comment


      #17
      I have an alternative that I thought I'd share.
      How is this even an alternative? Sounds like apples and oranges. Helper objects are helpful, sure. But let's say you need 100000 of these (actor will bog it down, structs will not), and then let's save the results to a save game object... You still need structs anyway. :] Unless your project is super tiny and holds 200 variables you're happy to save manually by hand.

      If you really want to do it this way (because it's definitely a valid if cumbersome method - I used it around 4.14 when structs were truly crashy), why not use actor/scene components instead? They're much lighter than actors, easier to instantiate, don't break like structs and are generally quite nifty. Consider that, or not.

      Of course, it all depends on what you need it for. There have been so many changes to struts over the years and they still do not work well enough for anything serious in BP :| Shame.

      Comment


        #18
        Originally posted by Everynone View Post

        How is this even an alternative? Sounds like apples and oranges. Helper objects are helpful, sure. But let's say you need 100000 of these (actor will bog it down, structs will not), and then let's save the results to a save game object... You still need structs anyway. :] Unless your project is super tiny and holds 200 variables you're happy to save manually by hand.

        If you really want to do it this way (because it's definitely a valid if cumbersome method - I used it around 4.14 when structs were truly crashy), why not use actor/scene components instead? They're much lighter than actors, easier to instantiate, don't break like structs and are generally quite nifty. Consider that, or not.

        Of course, it all depends on what you need it for. There have been so many changes to struts over the years and they still do not work well enough for anything serious in BP :| Shame.

        I'm quite new to Unreal, so I haven't yet gotten to attempt to save anything, it's possible I'll have to refactor yet again when I find that this method doesn't work out...
        When you say 'actor will bog it down', this Object type is simply an Object, not based off Actor so it should be fine?
        How would I use a scene component instead?
        Cheers!

        Comment


          #19
          He meant the default in-game save system in Unreal doesn't save Object types, only primitive types that are passed as values (not references).

          Since Structs in Unreal are "value types" all you need to do is re-assign the copy (result) of your modified Struct to the variable holding the "original" one once your changes to the copy are done.
          | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

          Comment


            #20
            Object type is simply an Object, not based off Actor so it should be fine?
            I just meant that there are situations where you're almost forced to rely on structs anyway - like the built in generic save game object system BPs are using; a system crafty folk replaces with a custom auto-save plugin...

            You probably do not need to refactor anything at this point. You can start using BP structs (or not) when you're ready to automate saving data. I was just making a point there - objects are not a replacement for structs or the other way round. Not in BP, that is.

            In C++ they're pretty close.

            Comment

            Working...
            X