Get Components by Class or by Tag: no referencing

The array that you get as output of the nodes “Get Components by Tag” or “Get Components by Class” is bugged. You are supposed to be able to use get with a reference or with a copy by choice. However, those arrays only allow getting “by copy”. If you then press rightclick on the output of the get node to change the output mode to “reference”, the description text while hovering above the get node is still saying that it’s a copy you are getting. When you then once again press rightclick on the output, the option to change the output into a reference is greyed out.

Here is a picture and a gif to shocase the problem

bump… (is that even allowed? And does it even work?)

Maybe a bit late on this, but anyway.

I’m not entirely familiar with the internal workings of the TArray in Blueprint, but what I do know applies to managed, object oriented programming: it shouldn’t matter.

Why is this? Because objects in C++ are commonly stored somewhere in RAM. All you have to access them is a so-called pointer. A pointer is nothing but a numeric address. You dereference these pointers to access the object behind them. Accordingly you can have various pointers to the same memory address.

This is what’s happening here. The object is somewhere in RAM (managed by UE4’s garbage collector, it’s address may even change at runtime), and the array merely contains numeric values that are interpreted as pointers to objects of a certain class. If you get a copy of such a pointer, you still change the actual object. If you were to get a reference of such a pointer, you’d be allowed to “rewrite” the numeric address of the pointer, effectively making it point to a different object.

As you can probably imagine, the latter is a rather uncommon use-case. So for most uses, it really shouldn’t matter.

I’m afraid not, the return specifically says it (will NOT) be propagated back into the array after you’ve changed the copy.