I’ve got an object that exists throughout the lifetime of the game. It’s visible and can be picked up and thrown around. I’m using client side prediction with server reconciliation to make the visuals look nice and clean. However, when I throw my object and the client spawns a new one and starts simulating, both objects can be seen.
The simulated throw is being executed by a server RPC. In said server “ServerThrow” RPC the server also calls SetActorHiddenInGame(true) on the ball. That’s great, ball disappears on the server. Shortly after, I set an OnRep variable that exists on the server ball “isHidden” to true. Then, I have a function “OnRep_Hidden” that calls:
this->SetActorHiddenInGame(true);
I’ve also tried using StaticMesh→SetVisibility(false, true), StaticMesh→SetHiddenInGame(true, true), etc… But this darn ball can still be seen on the clients!
I have many print statements that validate that the OnRep is happening, the value is correct, and even the StaticMesh itself returns 0 from IsVisible(). But again, can still see the ball!
I’m sure this is something stupid, but it has stumped me. Any help would be greatly appreciated.
Please disregard this post because I am very stupid. I will keep it up rather than deleting it because I learned some valuable things along the way.
Net ownership does not matter. You can call this on the client and it WILL hide the ball locally even if it’s owned by the server.
You might need to check that your RootComponent is the StaticMesh and not some other thing like a collision sphere if you’re attempting to do "GetRootComponent()→SetVisibility()”
You could possibly have a duplicate StaticMesh somewhere if you’re setting in both blueprints and C++
You could possibly have created a StaticMesh variable in C++ that is not tied to anything if you set the static mesh in blueprints
Take those suggestions with a grain of salt I am not a financial advisor… Err expert in Unreal.
If you’re wondering what my fix was? In all my wisdom of sending a NetMulticast to do Client Side Prediction I forgot to check if I was the server, so I was creating more than one authoritative invisible ball. Or something like that idk it’s tired I’m going to bed.
that’s very common, that’s why i rather check for isserver than has auth.
you can change properties freely on clients, without authority, but they don’t get replicated back to the server.
beware that changes on the server might or might not replicate back to the client.
this is important for variables with repnotify, as it might not update if you change them locally, there was a rule but i don’t remember top of my head atm.
also important in case you have something like a fog-of-war, a client can hide it and show the map if you replicate everything (same for scores, points, and invisible things).