Jump to content

Random additive scene loading when starting the scene


Matmalm
 Share

Go to solution Solved by Peter,

Recommended Posts

I'm using Unity 2021.3.6 and Gaia Pro 2021 3.3.0

 

In my player I have a terrain loader which loads the terrains according to its position in a range of 80, 80, 80. However, and this only happens when I instantiate the player into the scene, an additive scene in a medium distance from the player starts loading and then proceeds to unload. 

See the following video:

In the video Scene 2_3 is obviously out of range, as if 0_2 and 0_3 (where the player is) is being loaded, at least 1_3 should also load for 2_3 start loading

 

Link to comment
Share on other sites

This could depend on where the player is located in the world. 
Also terrain naming can be deceptive due to how the world is created in a grid like pattern. 
After you press play, go to the scene view and see why that terrain is staying there if not within the terrain loader range. 
There could be an object that is making it stay there or something attached to the terrain. 
Its hard to say without looking at the project. 

I also see a dontdestroyonload, check what is in there as well. 

Make sure that you unload all the terrain scenes and that they are added to the build settings as well before hitting play. 

 

Link to comment
Share on other sites

22 minutes ago, Bryan said:

This could depend on where the player is located in the world. 
Also terrain naming can be deceptive due to how the world is created in a grid like pattern. 
After you press play, go to the scene view and see why that terrain is staying there if not within the terrain loader range. 
There could be an object that is making it stay there or something attached to the terrain. 
Its hard to say without looking at the project. 

I also see a dontdestroyonload, check what is in there as well. 

Make sure that you unload all the terrain scenes and that they are added to the build settings as well before hitting play. 

 

The terrain (2_3) is not staying there, it's just loading and then unloading as it shows in the video. 

But it shouldn't be loading as it's out of range, what affect the game with loading (and then unloading) a terrain is that the loading time it takes from the UI to the gameplay is longer.

The terrain gets in the state is loading once the player is instantiated, then gets in the unloading state.

Link to comment
Share on other sites

There is a total of 36 terrains (from 0_0 to 5_5).

I just changed the position instantiation of the player to 2_0, it also loads terrain 1_0 which is correct.

However, it does the same behavior as before, but this time it loads and unloads terrain 2_2

Link to comment
Share on other sites

Yeah this is interesting. 
After looking at the video more carefully. 
It seems that the terrain that's not supposed to be there gets loaded in and then immediately unloads. 
image.png

Normally this shouldnt be the case. 

 

  • Like 1
Link to comment
Share on other sites

  • Solution

Hi @Matmalm, this indeed a bit unusual - normally if all terrains are unloaded at the start of runtime, only the terrains that are being in range of the Terrain Loader component on the player / camera. Can you please check in the Terrain Loader Manager if you have any other loader configured to load terrains during runtime?

image.png

If there is any other Gaia tool beyond the player / camera set to load terrains  during runtime, that might potentially cause the issue.

If this still gives no insights and if you are familiar with debugging, could you please set a breakpoint at line138 in TerrainScene.cs? This is the function "AddRegularReference" and this is called whenever an object requests that a certain terrain should be loaded - this would allow you to check where that odd request to load the terrain is coming from.


image.png

  • Like 1
Link to comment
Share on other sites

On 10/11/2022 at 12:08 AM, Peter said:

Hi @Matmalm, this indeed a bit unusual - normally if all terrains are unloaded at the start of runtime, only the terrains that are being in range of the Terrain Loader component on the player / camera. Can you please check in the Terrain Loader Manager if you have any other loader configured to load terrains during runtime?

image.png

If there is any other Gaia tool beyond the player / camera set to load terrains  during runtime, that might potentially cause the issue.

If this still gives no insights and if you are familiar with debugging, could you please set a breakpoint at line138 in TerrainScene.cs? This is the function "AddRegularReference" and this is called whenever an object requests that a certain terrain should be loaded - this would allow you to check where that odd request to load the terrain is coming from.


image.png

Thank you!

 

It was the player instantiation. Apparently, it was instantiating the player prefab on the position of the prefab, and then updating the position of the player to the spawning position of the vector var (a var which was saved before loading the scene), but for some reason it was updating the vector variable milliseconds after the prefab was instantiated.

 

I changed the prefab position to be out of the bounds, something like 10000, 0, 0, and now the terrains are loading correctly.

 

Yeah, it was something weird but on my end! Thank you for the help!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...