Download

What does pass by reference actually do?

I haev an event and I send struct by reference

what I expect is the values from the struct to get modified, but instead it does not modify the actual struct.

I add a array of struct items.

Any idea?

You’ll have to show us where that Event is being called as well. It doesn’t do any good to take something by value if a copy is being passed into the Event in the first place.

Thanks to reply. I will try to make a video it will be easy to understand not sure when though.

Passing by reference is passing by reference.
If you don’t actually know what that does or means…

  1. I’m glad you ask.
  2. did you ask Google too?

Every variable everywhere in all programming languages (or just about) resolves down to a memory address.
What the code does is instantiate a set of memory space according to what was asked during definition.
This is then given an address so it can be retrieved.

Passing by reference, essentially, is using that memory address to reference stuff.

How that differs from regular variables depends on how you are making use of the reference or variable.
Usually, passing variables by reference is better for performance - but as always, it’s a gray area in terms of what’s actually better, and there’s also considerations but the engine and what it does…

There is a game that generates an array of soldiers into a struct that gets saved… video explain everything and shows that won’t work.

Doesn’t look like you are passing by reference.
Normally pass by reference has a Diamond shaped pin.
If it’s round, it’s probably not a reference.

I will check it