I have some strange bugs in my game and at first I want to explain them to you.
The player can spawn a city on a map (think of it as a RTS game). When the player clicks on the map, the PController sends a RPC Call to the server to spawn the city and replicate it to the clients.
Since every player can have more than one city, the PlayerState has to keep track, which city is currently “focused”, so that every action like recruting warriors happens in the right city, the selected one. Therefore I added a ACity-Pointer to PlayerState.
When the client clicks on the city, I execute a SingleLineTrace to get the hitted actor and pass a pointer to it to an RPC call that tells the server that the client wants so change the focus to a different city.
At first, everything works, but at some points in my game, the trace suddenly get’s me a different city-instance. When I pass this city-pointer to the server, the server handles it correctly again, every, for example recruting, happens in the “right” city, the new selected one. It seems that there are suddenly two citys at the same location, but I added breakpoints to the constructor, no new instance is created, only one for every client.
I hope my fault is in the passing of the pointer. How would you identify a replicated actor on the client and pass it to the server?
Thanks so much!!