Download

[SOLVED] UPROPERTY(Replicated) keeps throwing obscure error.

I have a replicated actor ABoardGenerator, and within it there are two arrays of actor pointers (the actor derived classes are AGround and AUnit)



UPROPERTY(Replicated)
AGround** GroundBoard;
UPROPERTY(Replicated)
AUnit** UnitBoard;


I do have ABoardGenerator::GetLifetimeReplicatedProps defined in ABoardGenerator.cpp, along with the DOREPLIFETIME macros and the proper includes. Without UPROPERTY(Replicated) everything works fine, but with it I get this completely undescriptive error:



Error: Missing '*' in Expected a pointer type


That’s it. I saw a mention on the wiki that:

But the thing is, they are pointers, it’s an array of AGround*/AUnit*.
Thanks in advance.

Lesson of the day: use TArrays. Unreal grooves better with TArray instead of C style arrays. I probably should have realized this sooner, considering TArray comes with UE4.

You’re declaring them as pointers to pointers (double asterix). This is wrong, only regular pointers can be replicated (single asterix)

That’s also not how you declare an Array in C++, both in regular C++ or in UE4 C++. In UE4, you must use TArray<> to replicate an array of objects.