how does set member in struct work

I find two ways to set a structure in blueprint, set structure by ref and set member in struct. I use set member in struct to update struct in my project. In my view, set member in struct is more convinent for it can set and show single member. As I dig in, I ask the AI assistant for more imformation, and it said ‘Set Members in Struct do NOT change the original struct’, and I must set it back to update it, which doesn’t match the result when I use it.

So I make a small test:

The result shows the struct do updated without set back.

Then I do as the AI assistant suggested, and delay, use another event, and use function and local variable, they all updated without set back

So what do I miss? Or I am just doing ok?

1 Like

The whole point of ‘set members in struct’ is to update part of a struct

As is often the case, AI has it wrong, and is revealing itself once again as a distillation of all the garbage on the internet… :slight_smile:

Using a delay being a good summary of what is wrong. A delay is basically NEVER a good idea ( unless you actually do just need to wait ), but examples are full of it.

4 Likes

This could actually happen, but it depends on how you are getting the struct in first place, it doesn’t work when you use “Get” from an array, because by default it returns a copy of the value, not a reference (you can change this by right clicking it) and sometimes it also doesn’t work in loops or with widget structs, when you want to change the style for example: the get style function is probably returning a copy of the style and not a reference, so you have to set it back

1 Like

this. don’t forget the small text at the bottom that says “ai makes mistakes”.

1 Like

ah, I see these words now when start a new conversetion. They are too tiny, if AI makes mistake, it’s not a shame. They should make these words always shown and show obviously. Hard to say the tiny words shows confidence or inconfidence to the AI.

I’m a new user, so I assume the official AI assistant have a lower chance to make mistake. That’s why I come here to make sure.

1 Like

From my experience, AI makes a LOT of mistakes :smiley:

Almost any time I ask something, it gets it wrong…

2 Likes

I agree. A delay can sometime solve a problem temporary, but not accuracy enough for complex runtime situation.

2 Likes

The main problem with delays, is you don’t know what architecture the game will finally run on.

You might need a very long delay, if the game is running on a total potato. There’s no way to know.

So event driven is much better.

Anyway, using a delay when reading from variables makes no sense anyway. Either the value is there, or it’s not :rofl:

2 Likes

for me the same. any time i ask something is confidently wrong. it’s just pure trash. at the cost of humanity.

oh’ i’ve missed this. i agree.

the other big problem with delays is that is a shift in the way you think the algorithm. it introduces all sort of timing issues and race conditions, and problems with reentrancy. that without enough experience are very hard to catch. most people i see using delays don’t pay attention to that.

it also makes the code a mess. code with delays tend to spaghettification usually.

it also a weird construct really, compared to a strictly sequential program. it’s implemented in bp only, and only on events. and doesn’t work as “intuitively expected” in reentrancy cases.(e.g. triggering an event multiple times in a frequency higher than the delay allows).

you can’t move that construct easily to cpp, and not even a function. and even if you do, the code becomes also spaghetti. (yes i’m aware there are things like coroutines but they basically have the same issue).

the cognitive load increases substantially, for no real benefit. imho.

i don’t have a single delay in my code base. i do have timers.

1 Like

I do have ‘some’ delays :slight_smile: I use it when I want to wait for something. Could use a timer, I guess, but the re-entrancy problem is the same. Anyway, when I do use the node, things are only called once.

1 Like

not always. a timer can be cancelled. a delay is not afaik.

it’s ok, i don’t think it’s a crime. specially if you’re experienced and know what you do.

i just think for most new comers and medium programmers, is rarely the best option, mostly justified by “it’s the quickest thing i can do”. but short term rewards usually don’t lead very far.

but if you know when to use it, that’s ok.

i apologize for derailing the thread, i just like add some of my thoughts sometimes.

1 Like

So glad to see all these discussions. All is helpfull.

2 Likes