Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Title: Handling Runtime Spawning of Inactive GameObjects in a Pooled Laser System with NetworkTransf

Discussion in 'Netcode for GameObjects' started by firebird721, Nov 16, 2023.

  1. firebird721

    firebird721

    Joined:
    Jun 8, 2022
    Posts:
    101
    : Hello Unity Community,

    I am working on a multiplayer game where enemies are spawned dynamically during runtime. Each enemy comes equipped with emitters capable of shooting lasers. These lasers are constructed from various parts, including an origin, a main body, and a tip, with each part comprising multiple chunks. I'm utilizing Unity's Netcode for GameObjects pooling system for this, as detailed here: Object Pooling in Unity Netcode.

    My challenge arises with the spawning of these laser components. Not all chunks are active upon spawning but all of the,m has differnt local place so i added netrworktransform to each(maybe i dont have too?)
    ; some are inactive but may be needed to be activated later. Additionally, each enemy must have its own set of emitters, lasers, and chunks, all of which need to be spawned and managed effectively. This raises several questions:

    1. How can I manage the spawning of laser parts efficiently, given that some chunks are initially inactive?
    2. What's the best approach to handle inactive GameObjects within Unity's Netcode for GameObjects pooling system, especially when these objects have NetworkTransform components? i get a warning about problem when spawning non active object - i tried activating all the childrens before and the spawn and kater sidactivets them (here there is consdirations of client server etc)
    3. Are there any specific considerations or best practices for dynamically spawning each enemy with its unique set of emitters and lasers, ensuring optimal performance and network synchronization?
    all and all i need to use comlex lasers from the pooling ssytem when some of the childrens are in active before hand(in the editor iwanr flexiblaty to play with the numbers of chuunks active etc)

    Any insights,
    advice, or examples from similar implementations would be immensely helpful. I'm looking for the most effective way to handle this aspect of my game, which is critical for the gameplay experience.

    Thank you for your time and assis
     
  2. NoelStephens_Unity

    NoelStephens_Unity

    Unity Technologies

    Joined:
    Feb 12, 2022
    Posts:
    244
    You might contemplate cloning the NGO repository and opening the NGO Test Project. There are several examples and scripts/components that can provide you with some insights to creating various things.
    From a pool perspective, I would recommend looking at the SceneTransitioningAdditive manual test/sample:
    upload_2023-11-16_14-48-28.png
    As well as a simpler version is the PrefabPool sample:
    upload_2023-11-16_14-49-8.png

    If you want to just "browse" the samples and manual tests you can make a stand alone build and you will be presented with two sub-menus: Samples Menu and Manual Tests
    upload_2023-11-16_14-50-58.png
    See if any of the script in the samples and manual tests provide more insight.
    If not, please feel free to post any further questions or the like you might have.
     
    Last edited: Nov 16, 2023
    mishakozlov74 likes this.