Search Unity

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

Gravity Problems, Light Sources Don't Load, Multiple Scenes Management

Discussion in 'Game Design' started by Palampaloo, Feb 17, 2022.

  1. Palampaloo


    Dec 16, 2021
    Hello, I'm trying to build a house where players need to go to multiple rooms to collect cubes and bring them out to a central hallway. I thought about loading each room differently with the cubes spawning in each room and then unloading the rooms as the player exits. To enable the cubes to be brought out of the rooms, I used the DontDestroyOnLoad(gameObject) method, but when the room unloads, the cubes will fall into the void.

    Is using an empty game object hovering in the room and using cube.position = hover.transform.position a good work-around for this gravity problem? It won't let me bring the cube out of the rooms, but it prevents the cube from falling to the void.

    Would it be better to set an invisible floor that loads after the player leaves the room instead?

    The lighting in each room also gets disabled every time I load my scene, is this a common problem? (As shown in the pictures)
    I tried putting the light source as a child of the Room, but it still won't load any light source. Is there something I'm missing about light sources?

    Thank you in advance for any help, I'm new here so a direction towards older threads are welcome!

    Attached Files:

    Last edited: Feb 17, 2022
  2. angrypenguin


    Dec 29, 2011
    Without knowing why you're doing it, I would most likely solve this by not unloading the rooms. What problem is that solving?

    It might be a good idea to turn off lights / renderers / etc. if you don't have some form of occlusion culling going on, but unless there's some heavy resource usage going on or you're aimed at very low end platforms then unloading/reloading/handling of shared objects is likely to be making things far more complicated than they need to be.

    Also, for what it's worth, in my multi-scene games I have a separate scene which handles any objects shared between other scenes. It doesn't really matter what place they start in, my game only cares where they are now. What if the player loads a game and then goes to where they put something before going to the room it originally spawned in?

    I suggest it would be better to deactivate the GameObject, and only re-activate it when the room it is in also becomes active again.