I have objects with physics on the level. Then the players move to another one and I save the coordinates of these objects. And when the players return to the original level, I delete all the objects from it and upload new ones. Everything is fine with the server, but with the client, they first spawn, interact with those that are initially there, and then only those that were are deleted. As a result, all the client’s objects fly apart. Can you help me solve this problem?
There are several things I would try:
- Disable collisions and hide before deleting the objects. Chances are it wont work but it’s worth a try as it seems easy to do.
- Can you try manually deleting the objects on the client and delay a bit the spawning of the new ones hoping that this will happen before the server sends he new objects.
- The cleanest way - forgo objects in the level altogether. Make a script that deletes them from your level and stores them always in the save game. Your level should be loaded clean and populated every time.
Replicated actors are auto destroyed by the engine when the player leaves the actors net cull distance radius (NCD). They will respawn in their correct locations/rotations etc when the player re-enters NCD.
If you are changing levels (load level), then you need to disable physics before spawning (exposed vars + construction script). You may also need to create overlap collision sphere’s to re-enable collision when the player gets close enough.