Hello guys. I’m newbie to the Unreal Engine C++ and don’t know much about syntax in the UE4 but i’m still learning. How can i access MinLifespan and MaxLifespan in PooledObjects.cpp from Spawner.cpp. I really don’t understand the syntax.I need someone to show me.
Here is my code :
But this will only work if you declare Min/MaxLifespan as public in APooledObjects because member variables are private by default. Please note that LifeRef is not a reference but a pointer. The operator -> is used to access a member variable from a pointer to an instance or struct.
Also I would recommend to work through some tutorial teaching the basics of C++.
Thank you j.mueller for replying. I try the steps that you stated earlier. Min/MaxLifespan already declare as public but still it didn’t work. Is there any other solution?
I didn’t receive any error but the variable Min/MaxLifespan still can’t be accessed from spawner.cpp. I try to change the value of the Min/MaxLifespan variable in editor through spawner but it didn’t work. APooledObject is not subclass of UWorld.
I try the code you stated above and i get this error.
a reference of type "TArray<AActor *, FDefaultAllocator> &" (not const-qualified) cannot be initialized with a value of type "TArray<APooledObjects *, FDefaultAllocator>"
Try TArray<AActor *> Actors; in Line 1 instead. Using APooledObjects would do an implicit upcast of all actors, what would be invalid for actors of a different class and that´s why the compiler refuses to accept this array.