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.
- Yeah, i tried to disable physics for items on event BeginPlay and then turn it on. It seems to work, but it needs to add new physics changing logic and it seems to me that there is a high chance that something somewhere will break.
- It was first i tried to do. I tried to destroy, disable physics for old items on client after event onPostLogin but there is no effect.
- When i handle with this problem i think about having two versions of level - with items and without. One will be initial level and than use only other version. The advantages are that there are no problems with transferring data between levels. Main disadvantage is that i need to support two versions of level - when i change one (adding SM) i need to synchronize changes on other.
If you have any suggestions, I would be glad you share them with me!
It seems to work, but could there be problems at the moment the client is loaded and host is enough close to items or even interacts with them in some way?
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.