Setting from Struct not (entirely) working

So this is a bit of an odd one I think, but bare with me here while I explain everything.

Basically I’ve set up an actor that has 10-12 Planes all set with partially transparent materials, all 0.01 units separated to create a sort of illusion of layers similar to art programs. This allows me to change the materials of each layer and the material colours of each layer to randomize things for when I spawn the actor. (They’re flat creatures with different markings, base colours, eye colours, etc). I am creating dynamic materials and adding them to variables in order to colour them and save them.

I have saved everything into a struct when someone clicks a button near a spawned actor, in order to call it later when spawning a saved/caught creature. (Don’t mind the cast to, I’m removing that I know it’s redundant)
This actor is where all the randomization happens. All of that is working (if you need visuals on those just ask me, but it’s too much to post in this initial post)

I then have a copy of the creature actor that only creates the dynamic materials for the markings, base colour, eyes, etc. and turns them into variables to use elsewhere.

So: I have Actor A with dynamic materials that randomize colour and then save those randomized colours into variables seen in the pic above, and I have Actor B that creates dynamic materials to then call later so I can set those materials in Actor B using Actor A’s saved information.

Now here’s the problem I have: All the marking colours work fine, but the primary, secondary and eyes are all randomizing colours when I spawn Actor B instead of taking from the struct that was saved.

Here’s what I have for loading the struct information (the spawn actor is spawning and getting information from Actor B) (I hope this image works it’s long…)

And here’s where I’m setting the dynamic materials for the markings (first image) and the primary/secondary/eyes (second image)

Please feel absolutely free to tell me if I’m doing anything dumb here, I’m still fairly new at things. Also if you need any extra info please let me know I have no idea if I gave enough.

Hey @AmaiTrick!

So before I deep dive into your stuff here let me just explain a nuance of structs that is not well explained or communicated if you’re not already in the know!

“MAKE” or “SET” doesn’t set the values… it sets the options. What you need to use is “Set Members”! “Set Members of Struct” is what most of us would consider using a “SET variable” Node!

Try using that to fix your issue and I bet that’ll do the job! For instance instead of adding “RHunDMStruct” as it’s created, create it THEN use “Set Members of Struct” to give your specific settings to the new struct before adding it to the array! :slight_smile:

Hope that helps!

1 Like

Thanks for the reply!!

Just to be certain, is this what you meant?

If so, it’s still unfortunately not working as intended :frowning:

Edit
Oopsie forgot to take out the redundant cast. Fixed that, ignore it again in the image.

Close! You’ll have to click the “Set Members in Struct” node and in the details expose the things you would like to set! It will only show the pins you tell it to! :slight_smile:

Omg I feel so dumb for not noticing that Ahahaha thank you.

Alright I have it set up like this (I’m still pretty new to structs hence not knowing the difference that you mentioned, I assume the ‘get’ node is what it wants here from the captured creatures struct):

Unfortunately still having the same issue as before.

Edit
Also tried connecting my CreatureData variable (struct variable with my struct data) into the Set Members ref and still same issue as before. Again, the marking colouring is working so it is pulling properly from the struct and saving to the struct, but something’s not working with the Primary, Secondary and Eye colours… I’m suspecting it has to do with the way I’m setting the dynamic materials but I’m not sure what’s wrong about them.

i think the issue is you’re adding a new copy (index++) but getting index 0.

with your current setup use GetaRef instead of GetaCopy and it should work (remove the ADD) or use SetArrayIndex(0) instead of ADD

Thanks for the reply!

I don’t see a SetArrayIndex node (Unless this is a variable type you’re referring to)
Sorry I am still fairly new to all this!

sorry its SetArrayElement.

the tricky thing with structs is knowing when you have a Copy or a Ref.

its worth looking into because if in the future you get you return your array/element by function (ie GetCapturedCreatures) you now have a copy again and it wont work.

for now you should be good though