Announcement

Collapse
No announcement yet.

Trying to understand struct variables

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

    Trying to understand struct variables

    hi i am new to UE4 and am wondering about struct variables . For example i have some traps that are disabled with an attached child button panel. I want to save them as they are disabled, so they remain disabled when i load game.it is said i can make a struct or add a custom variable to a struct for this.i can see in the trap bp a node section for deactivating the trap, but i dont see and variable option there to save after it is deactivated. I assume i cant just add a variable to struct like “ trap deactivated” and make it a boolean and it will save the trap after deactivated. Do i need to use a variable that already exists somewhere?Or can i make the above mentioned one and add some nodes in the trap bp to reference it?i mean if i add a variable do i need also do something in the trap bp nodes or other place to make the variable work? —— would i then need to add this variable to the trap bp , my character bp , and savegame bp to use it? thanks for any help
    Last edited by razmaz51; 04-16-2018, 12:44 PM.

    #2
    So If I'm understanding your question correctly. What you need to do is define the struct to have a variable, isEnabled, and then set this to true or false when needed, If you are trying to load them into another level you will need define that behavior. And if you are talking about exiting the game, and then reloading the game, you want that too be saved, then you got to save game state or save the information in txt files, and then on load of the game, read the text files, and spawn traps in locations, with the isEnabled boolean set.

    Comment


      #3
      Well i have a save game bp and save game nodes(OnSaveGameSave) and save game restore nodes OnSaveGameLoad, which i can normally just add a variable to SaveGame bp and splice in the variables (“set “ and “get”)in OnSaveGameSave snd OnSaveGameLoad to save and reload things. But with the traps tried everything from all kinds of variables and some Enums and arrays,but nothing seems to save the traps i already deactivate.they are on again on reload. So was told to add a variable to a struct, but dont know much in general about adding variables to structs , hence the questions above.

      Comment


        #4
        Edit the trap struct where it is defined? or go into the Trap BP, and under the variable section add a boolean, too keep track off their activation.

        Comment


          #5
          What kind of boolean ? Does it matter what i name it?if i do this do i need to do anything else to the trap bp other than just add the variable? Thanks for help.
          Last edited by razmaz51; 04-16-2018, 04:10 PM.

          Comment


            #6
            this is the last variable I tried , owned keys works for saving keys, but I tried all those arrays and variables below owned keys on the left for the traps Click image for larger version

Name:	trap deactivated.png
Views:	12
Size:	454.3 KB
ID:	1462015Click image for larger version

Name:	trap deactivated 2.png
Views:	12
Size:	546.9 KB
ID:	1462016 , so far nothing has worked.

            Comment


              #7
              I noticed the variable I created and added "trap deactivated" , when I check or uncheck its value default box , nothing changes, so I guess its not working . the variable that was already there and came with the trap bp, ("start trap activated"), when I uncheck its value default box and play , the trap is deactivated. so apparently it works.

              Comment


                #8
                any ideas?

                Comment

                Working...
                X