Announcement

Collapse
No announcement yet.

Struct, how to get a reference of a struct, not the copy of it. Pointers?

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

    Struct, how to get a reference of a struct, not the copy of it. Pointers?

    So we have actor.

    .................................................. .
    Actor has a cool struct called MyStruct.
    We make a get function.

    Code:
      Function StructType GetMyStruct (){  return MyStruct;   }
    And i want to modify the struct MyStruct through that function.

    Code:
      self.GetMyStruct().ValueA = 10
    Any idea ?

    gets and sets make code cleaner, than direct accessing.

    #2
    I don't think it's possible like that. Either directly access it (which you indicated you're trying to avoid, yet you're still directly accessing the struct members) or do it the other way around and instead provide SetMyStructMemberX(TypeOfX Value) functions. That way it's ok that you're only getting a copy and in order to actually set the MyStruct members you're again using Set functions instead of direct access.

    Comment


      #3
      Thanks for the information, i guess i can just go and, instance a whole new struct in the beginning of the function, then assign, with the actual one with a GetStruct, and afterwards go and set it with the NewOne And just, yeah do that... I fear it's a little bad for RAM, and such and processing and so but.... well it doesen't look to be so bad in gameplay. I have 0 idea.

      Comment

      Working...
      X