Jump to content

How to make Trigger Loader to work

Go to solution Solved by Peter,

Recommended Posts

I created a Trigger Loader (box collider with isTrigger checked, and SECTR trigger loader component with that new chunk assigned to it) -- but at runtime, the chunk is loaded using the Region loader, not with the trigger loader. Is there something else I need to do to make it respect the trigger loader?


The documentation (p 34) doesn't give a lot of troubleshooting details:


Trigger Loader

This component lets you load a list of Sectors whenever a particular Unity Trigger is activated. These same Sectors will be unloaded whenever the trigger is deactivated (provided no one else is trying to load them)

Link to comment
Share on other sites

Hi @gecko64 please excuse the delayed response! The problem is that there is no inherent mechanism in SECTR that "knows" that you intend to load that specific sector by the trigger loader - if the region of the region loader touches that sector, it will load it in. This is by design, the first loader type that creates a reference to a sector "wins" and results into loading the terrain, there is no logic that will avoid loading in a sector because a different loader type is also present in the scene.
What you could do to make this work is to put the "trigger-loaded" sector on a different layer instead - note that the region loader has a setting to load sectors on specific layers only:

In this way you could put the trigger loaded sector on the layer "SECTR Trigger" for example, and make the region loader ignore that layer, then it should work to load that sector in via a trigger later without the region loader interfering.

Link to comment
Share on other sites

Thanks for the help. So I've done that and now have:


1) All the main Sectors (for the Region loader to use) are on the Default layer (as they always have been, though some children are on various other layers, but that doesn't matter, right?)


2) On the Region Loader, the Layers to Load is Mixed -- all layers are selected except a new SCTR Trigger layer I created.


3) I changed the layer on the Trigger Loader colliders and on the sectors assigned to them (which I'll call Interior Sectors), to this new SECTR Trigger layer. 


At runtime, the new Interior Sectors are not loaded by the Region loader, which is good, but they're not loaded by the Trigger Loader either. No errors or anything in the console about these interior sectors. (They are in the build settings.)


The Trigger Loader just needs a Box Collider on it, with IsTrigger enabled, right? Any other ideas about why this isn't working?





Link to comment
Share on other sites

  • Solution

Hi @gecko64 I did make a test setup in the open world demo scene where I put one of the terrain sectors on a different layer which I ruled out for loading in the region loader. This terrain would not load anymore then. Then I added a new game object with a trigger box collider, and a SECTR Trigger Loader on it. I set the Trigger Loader up to load that one sectr on the different layer, and that worked.


My guess is the collision is not working on the trigger collider, does your player object have a rigidbody or character controller on them? If I remember correctly this is required to activate a trigger. Can you add a simple script to write something into the console when the trigger is being entered? 
Alternatively you could set a breakpoint in the "OnTriggerEnter" function in the SECTR_TriggerLoader.cs if you are familiar with debugging to see if that is being called when the trigger is entered.

Link to comment
Share on other sites

Thanks for the tips. Turned out the problem was that physics interactions were not enabled between the player and the Trigger Loader layers, d'oh! All working now. 

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