Where I add all actors of a class to an array, then call the array from inside a UMG HUD blueprint graph. It won’t run as the c++ node is ‘target, self’.
What SHOULD I have as the target for it? A reference? Or do i need to make it static and remove the target pin?
Try removing “BlueprintCallable” from the UFUNCTION() Makro.
Your “BlueprintPure” is already a function that can be called without an object of that class created.
I would also say you better create an array INSIDE of the function, fill it, and return it. Because without an object
i’m not sure if the array exists.
If you use BlueprintCallable instead of BlueprintPure, you will need an object of that class. That means you will have
to spawn the “AListMesh” and then use a reference of that spawned actor.
You can also step back from using an actor and create a UObject. Then you could create the object and call the function.
You would only need a BlueprintPure function that creates an UObject of your class and returns it (there is a tutorial
from Rama i guess and Ramas Plugin also contains such a node).
But for testing if it would work, change the UFUNCTION to:
Do this. You need to use a pointer here. Also why don’t you just save the actors in an array. Use your function and save the returned array in your GameInstance
or GameState. A class that you can access from everywhere.
Good call re saving as another array. First though… This now dies on the ADD line. If i comment it out, it runs. do i have my syntax wrong? I have tried with Add(); and it errors.
Error 1 error C2664: ‘int32 TArray<AStaticMeshActor *,FDefaultAllocator>::Add(AStaticMeshActor *const &)’ : cannot convert argument 1 from ‘TObjectIterator<AStaticMeshActor *>’ to ‘AStaticMeshActor *&&’
4 IntelliSense: no instance of overloaded function "TArray<InElementType, InAllocator>::Add [with InElementType=AStaticMeshActor *, InAllocator=FDefaultAllocator]" matches the argument list
argument types are: (TObjectIterator<AStaticMeshActor>)
object type is: TArray<AStaticMeshActor *, FDefaultAllocator>
Error 1 error C2664: ‘int32 TArray<AStaticMeshActor *,FDefaultAllocator>::Add(AStaticMeshActor *const &)’ : cannot convert argument 1 from ‘TObjectIterator<AStaticMeshActor *>’ to ‘AStaticMeshActor *&&’
4 IntelliSense: no instance of overloaded function "TArray<InElementType, InAllocator>::Add [with InElementType=AStaticMeshActor *, InAllocator=FDefaultAllocator]" matches the argument list
argument types are: (TObjectIterator<AStaticMeshActor>)
object type is: TArray<AStaticMeshActor *, FDefaultAllocator>
[/QUOTE]
Have you tried “.Add(*Itr);”?
Itr is an iterator, not the actual pointer, so you should need to dereference it before you get the actual pointer.