Struct returning Zero

Hello all i have ran into an issue where i have some ai running around on the map and when i click on them it gives me some details about them. I have used a struct to keep everything together then i have a parent character that fills in the info when the character spawns in with the event construct. Say one of them is the age i use a random int in range between 21 and 65 and set an int with that and use that int to set the struct but sometime it comes up as zero even though i have set the range has anyone got an idea on why this might be ?

cheers

Show us how you update the struct.

Im not sure if this is the correct way to do it but it is all done in the construction script of the parent character I generate the stats their and feed it to the struct thanks again for helping

So you make a new struct from scratch, this should work.

Can you elaborate on this? How often is sometimes, any special circumstances, you’ve noticed a pattern perhaps? Is the random ranged float the only var in the struct returning incorrect value?

ill go over what i have done to generate the character its probably not the best way any info would help.
I have the parent character generate the stats as above and sets the info in the struct.
i call this from the game mode (im not sure if this is the right area to call it from ) which calls a spawn ai from class which i use the parent class and a select node with a random int in range for it to generate a character from one of the child classes i made from the parent class and i set that as a new character reference.
Then in my widget on construct i call the game mode event to generate the new character and use that characters struct info to fill in details with in my widget.
The things i have is Age (generated from a random int in range ) mood ( generated from a Enum ) Skills ( generated from a Enum) so what will happen when i call the widget it will generate the info sometimes it will just say none in the in the enums and the age will be 0 If i close and open the widget i get every thing as none and 0

My goal is to have a get it so the game generates a random character with random variables and i can select them from a widget that will place them in my game when i press hire.

Thanks for your help it is a little over my head

I mean, your method sounds fine. I was more interested in the

The sometimes spiked my curiosity; impossible to tell from the pics and the description why some variables are set while other are not. [HR][/HR]However, it seems there’s no need for the character to exist until they’re hired right? Perhaps rather than generating a character and then populating their variables, have the widget generate the character data and then spawn it.

  • have a struct variable in the character (exposed on spawn and editable)
  • have the widget generate data to visualise the avatar’s potential
  • *Hire *button reads the data (off the display or variables), makes the struct and spawns the character - this is where you plug in the struct
  • the character is then free to handle the struct (create their own widgets, apply the struct and so on) - this way you can utilise the character’s Construct Script as well.

There are many ways of achieving it, of course. Some more suitable than others.

Thanks for your help !!! I ended up creating a Data table making around 50 different rows with random values in them for the struct, i then used a get table row names randomized it got the struct info and set it to a local struct info that is used to generate the character and set the widget info. Also since i have gone down this path i have no issues in generating a characters stats.

Thanks again