Jump to content

Issue with terrain not loading correctly in build but loads fine in editor


EpicVr
Go to solution Solved by EpicVr,

Recommended Posts

Hi!

I'm working on a project where we have a large terrain divided into smaller chunks in scenes. During game tests in the editor, the terrain loads without any issues. However, when we try to run the game on a build, the terrain fails to load, causing the player to fall through the map.

We have investigated the logs in the development build and found no errors when switching to the scene with the terrain. We're puzzled about why the terrain is not loading properly in the build while it works perfectly fine in the editor.

Has anyone experienced a similar issue or have any suggestions on how to resolve this problem? We would greatly appreciate any help or insights you can provide.

Thank you!

Link to comment
Share on other sites

@Bryan Thanks for response!

Quote

How is your player setup? 

I'm using custom player from HurricaneVR.

Quote

Do you have the terrain loader script attached to the player? 

Yes and as I wrote above - everything works fine in the editor, even when I switch from another scene to the one with the terrain 🤨

If it helps I can send some screenshots of our player setup.

Link to comment
Share on other sites

Yes, often encountered to add the network ...

You can check the collision Detection of the player's RigidBody.

On your Player, a script is added by Gaia: RigidbodyWaitForTerrainLoad.

It is in this script that the Player is suspended and it is here that you can add time or test booleans, or ect ...

like :

Invoke("ActivateRigidbody", m_activateDelay);

void ActivateRigidbody()

{

m_watchedRigidbody.useGravity = true;

m_watchedRigidbody.constraints = RigidbodyConstraints.None; ... // Your function

Destroy(this);

}

If you modify this script, to prevent it from being overwritten during updates, I suggest that you add your own (copy, change name and class), and deactivate the original.

Link to comment
Share on other sites

21 hours ago, Meudes said:

Yes, often encountered to add the network ...

You can check the collision Detection of the player's RigidBody.

On your Player, a script is added by Gaia: RigidbodyWaitForTerrainLoad.

It is in this script that the Player is suspended and it is here that you can add time or test booleans, or ect ...

like :

Invoke("ActivateRigidbody", m_activateDelay);

void ActivateRigidbody()

{

m_watchedRigidbody.useGravity = true;

m_watchedRigidbody.constraints = RigidbodyConstraints.None; ... // Your function

Destroy(this);

}

If you modify this script, to prevent it from being overwritten during updates, I suggest that you add your own (copy, change name and class), and deactivate the original.

 

Ok, I modified the RigidbodyWaitForTerrainLoad script like this. I'll try to make a build and see if they load correctly now. 🤞

public class RigidbodyWaitForTerrainLoad : MonoBehaviour
    {
        HVRPlayerController playerController;
        TerrainScene terrainScene;
        bool invokeStarted = false;
        float baseGravity;


        public float m_activateDelay = 2f;
        public List<MonoBehaviour> m_componentsToActivate = new List<MonoBehaviour>();

        void Start()
        {
            if (TerrainLoaderManager.TerrainScenes.Count <= 0)
                Destroy(this);
            else
                Setup();
        }

        void Update()
        {
            if (terrainScene != null && terrainScene.m_regularLoadState != LoadState.Loaded)
            {
                playerController.Gravity = 0f;
            }
            else
            {
                if (!invokeStarted)
                    Invoke(nameof(ActivateRigidbody), m_activateDelay);
            }
        }

        void Setup()
        {
            playerController = GetComponent<HVRPlayerController>();
            baseGravity = playerController.Gravity;
            foreach (TerrainScene terrainScene in TerrainLoaderManager.TerrainScenes)
            {
                if (terrainScene.m_bounds.Contains(transform.position))
                {
                    this.terrainScene = terrainScene;
                    playerController.Gravity = 0f;
                }
            }
            if (terrainScene == null)
                Destroy(this);
        }

        void ActivateRigidbody()
        {
            playerController.Gravity = baseGravity;
            foreach (MonoBehaviour component in m_componentsToActivate)
                component.enabled = true;
            Destroy(this);
        }
    }

Link to comment
Share on other sites

@Meudes Still the same thing - editor is fine, on build player is under the terrain 😔

 

@Bryan I have this components on player object and Location System on Camera. I should also add that I don't use FloatPointFix that shifts the scenes around.

image.png.37dc1726c8a9295325483c39fcdfbed4.png

Link to comment
Share on other sites

I might have a solution but I will have to pull up my old VR project I will get back with you as soon as possible. 

  • Like 1
Link to comment
Share on other sites

image.png

I just made quite a few tests and everything is working both on the build and editor. 
I would say this does have to be a character issue. 

 

Link to comment
Share on other sites

Thanks, @Bryan. Unfortunately, I've created additional builds, and on one of them, with an empty scene using the player prefab I've been using, everything worked fine. However, when I create a build with just the Gaia terrain scene and the same player, I get a completely black screen on my monitor. Meanwhile, on the headset, only the game logo flickers, indicating a lack of a camera in the loaded scene. 

It seems to me that there must be something with the Gaia configuration or perhaps the build settings. Unfortunately, I have no idea what could be causing such behavior...

Edit: Previously, the player was flying under the terrain because I didn't notice that its the player from the previous scene because he was set to DontDestroyOnLoad. Now I realize that the real issue is that Gaia is removing the player (or something like that) from the scene in the build.

Edited by EpicVr
Added more details
Link to comment
Share on other sites

If it's working from the editor not in a build that would indicate that it's a rendering issue or SDK issue. 
Without getting in the project myself its going to be quite complex to actually try and figure out. 
If you would like reach out to me on discord, and we can potentially get on a call and try and figure it out. 

 

  • Like 1
Link to comment
Share on other sites

  • Solution
On 6/17/2023 at 1:48 AM, Bryan said:

If it's working from the editor not in a build that would indicate that it's a rendering issue or SDK issue. 
Without getting in the project myself its going to be quite complex to actually try and figure out. 
If you would like reach out to me on discord, and we can potentially get on a call and try and figure it out. 

 

@Bryan thank you so much for your time and assistance in resolving the issue! 😊

I don't know how, but I managed to track it down. It's related to the 'Gaia Tools' object. When it's disabled, the build works perfectly. Interestingly, when I create a completely new scene and generate terrain, everything works without having to disable 'Gaia Tools'. I've checked, and it seems that everything is the same as in that clean scene, so I have no idea what could be causing the problem. Do you have any ideas? Disabling 'Gaia Tools' is a temporary solution, but I'd like to find out the cause of this problem to avoid having to do it again in the future 😅

A while ago, we were updating Gaia to version 3.3.6-c5, and I'm not sure if we ran Gaia Maintenance. Could that be related? Because honestly, I have no idea how an object with the 'EditorOnly' tag could break the build.

Link to comment
Share on other sites

To be honest I am not sure, in my testing the build worked with the tools still in the project and in build. 
However, in the past I remember disabling most of the runtime and Gaia Tools to save performance. 
We will look into this and see what can be done. 

  • Thanks 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
  • 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...