'Owner'-Variable = NULL when spawned on Server

Hey!

I spawn an City instance in a UFUNCTION(server, reliable, WithValidation)'s _Implementation function, using this->GetWorld()->SpawnActor();

After this, I call for this instance ->SetOwner(this), where ‘this’ is the PlayerController.

The object gets spawned, and everything replicated nice between server and client. Except one thing. When I click the
City, I have a function to determine if the PlayerController, who clicked the city, is actually the owner of the city.

bool ACapitalCity::isPlayerOwner(APlayerControllerImplementation* controller){

	AActor* act = this->GetOwner();
	if (this->GetOwner() == controller) return true;
	else return false;

}

I added the AActor* act for debugging reasons. Now, if I spawn the city using the Client’s Game and click on it, both server and client, the function returns the right answer, eg the Controller is replicated and not NULL. Different, when I spawn the City on the Servers Game Instance. I trigger the spawn event, the _Implementation function is called, the Object spawns with the explained function and setOwner is called, and the (this) variable (The servers PlayerController) is a valid PlayerController (not NULL). But, when I click the city, spawned by the server on the server, both client and server don’t have any PlayerController stored inside them.

I get the object by a SingleLineTrace and a FHitActor. The strange thing is, when I look at the memory cell name (I hope you know what I mean, the 0x000000000fcb200 thing), they are not the same (The returned one from the SpawnActor() function and the returned one from the HitResult.GetActor() function, but a bad trace, returning a wrong instance is impossible since their is only one) But this behaviour also occurs on the client side, where everything works, so I guess thats normal, isn’t it?

However, do you have any ideas why this problem occurs? I am so confused because I would rather excpect that the client doens’t replicate correct to the server, but that the server itself looses its own data worries me a lot…

One thing to mention: When I store a simple int32 variable in this instance, they are both accessable, on client and server…

Thanks! :slight_smile:

Even stranger: With a dedicated server, this behaviour is exactly the same, but instead of for the server for the second client…

Ok, apparently, the functionality only works on the first client. All other clients and the server point to a NULL…