Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question [Fish-Networking] Issues with using multiple scenes.

Discussion in 'Multiplayer' started by freeze426, May 13, 2024.

  1. freeze426

    freeze426

    Joined:
    Feb 17, 2018
    Posts:
    8
    My English isn't great, so I'm using ChatCPT for translation.

    I referred to the AdditiveScenes scene.

    The ideal operation is as follows: When the server presses Server, all game scenes are loaded, and objects on all scenes are generated. Players can also connect as clients to play. After objects are generated on the scene, they are set with parent hierarchy and position. When other clients connect, only the initially connected scene and the current game scene are loaded, similar to the AdditiveScenes example.

    However, the current situation is that when the server also becomes a client, other players will encounter messages saying they can't find the specified object (can't find parent) after becoming clients. I've tried many methods but haven't been able to solve this.

    This script loads all scenes when the server starts.
    upload_2024-5-14_3-33-2.png

    This script loads or unloads scenes upon triggering a trigger.
    upload_2024-5-14_3-34-35.png

    This script is a manager for object generation in the game scene.
    upload_2024-5-14_3-36-4.png

    This script synchronizes the positions of generated objects.
    upload_2024-5-14_3-37-29.png


    There are still some issues, but only five images can be posted in one article. I'll continue in the reply.

    The forum doesn't allow posting .mp4 files, but I've posted the relevant videos on Discord.
     

    Attached Files:

  2. freeze426

    freeze426

    Joined:
    Feb 17, 2018
    Posts:
    8
    Players can shoot bullets, and the survival time of the bullets is calculated by the server. After a few seconds or hitting a target, the bullets will despawn. However, if a player moves to another game scene before the bullets despawn, a message "NetworkObject for ObjectId of 40 was found null. Unable to despawn object. This may occur if a nested NetworkObject had its parent object unexpectedly destroyed. This incident is often safe to ignore. UnityEngine.Debug:Log (object)" appears. I can't find a way to remove this message.

    This script handles the timing and despawning of bullets.

    I also just modified the bullet script to have the server despawn bullets. However, when changing scenes on the client side and the server deletes bullet objects, I get the message "NetworkObject for ObjectId of 40 was found null. Unable to despawn object. This may occur if a nested NetworkObject had its parent object unexpectedly destroyed. This incident is often safe to ignore. UnityEngine.Debug:Log (object)". Although it doesn't affect anything, I'd like to clear it.

    upload_2024-5-14_3-43-41.png

    Finally, following the script from the AdditiveScenes example mentioned above, when the server becomes a client and then stops being a client, the first scene is lost (the first scene includes lights and cameras).

    When running the client for the first time.
    upload_2024-5-14_3-50-40.png

    When stopping the client.
    upload_2024-5-14_3-51-19.png