Jump to content

Trigger Loader problem when switching to another player-character


gecko64

Recommended Posts

We've got SECTR streaming working great in our game for almost a year now. But now we're adding a feature where the player can switch into another character for a short period of time. The other character has the SECTR Region Loader on it, and we disable the Region Loader on the main character and enable it on this secondary character -- that works fine. For the Trigger Loaders to work, we have to change the layers: switching from Player layer on the main character to something else, and switching the secondary character to Player layer. And this isn't working well -- when the player-controlled secondary character enters a trigger loader collider, that chunk loads multiple times -- like 10 or more instances of that chunk are loaded, and some of them are also constantly being unloaded and loaded. Very very odd. Any idea what could be going on there, or how to fix it?

 

thanks

Dave

Link to comment
Share on other sites

Also, when switching characters and disabling and enabling the Region Loaders, all the regular SECTR chunks around those two characters get unloaded, then reloaded. Is there a way to avoid that (since you can only switch characters when the two are next to each other)?

Link to comment
Share on other sites

Sadly, I am not sure how to fix it. 
Due to the main character being the loader and unloader and then switching to the secondary character, it would act like it's being loaded for the first time. 

I would imagine that in your scripts you would need to add the logic to connect and share the loaded terrains and then still have a secondary loader attached to the second character. 

 

Link to comment
Share on other sites

as for the reason for multiple instances of the chunks being loaded, I have never seen that issue. 
Is it only happening if you are trying to do it with both players, but it doesn't happen when its a single player? 
It could be trying to grab both at the same time? Do you have any debugging to see if your scripts are actually turning off the first character? 

I also think it would go along with my first answer. 
I would honestly try to solve that logic first and then worry about the duplication issue. 
You might solve both at the same time. 

Link to comment
Share on other sites

When switching to a Region Loading on another character, the unload and reload makes sense, I don't think that is a bug, just how it works. I think that's unrelated to the first/main issue, where the Trigger Loader is behaving very badly. Is there anything else that needs to be switched, when changing characters, for the Trigger Loader to work properly?

Link to comment
Share on other sites

That's where I am not sure, it would be conflicting with the two players. 
Sectr wasn't designed to handle that, so I have never tested how to do that properly. 
Can you try and keep the trigger loaded persistent, or do not destroy / disable? 

Link to comment
Share on other sites

Well, wait no because if it's duplicating itself that's where to problem might lead, is the fact it is being duplicated that way. 

If you disabled the trigger loader on one or destroyed it when switching does that fix the issue? 
You could just need to add the component during the switch and destroy it on the player not being used. 
The only fear would be the in-between.  

Link to comment
Share on other sites

Hi @gecko64,

I reviewed this issue and took another look at the Trigger loader and currently I could not imagine what would cause this. You mentioned that "multiple instances of a chunk" are being loaded in - how does this look like in the scene hierarchy? Normally the chunks are being loaded in as additive scenes, which can only be loaded once, so it should - in theory - not be possible to have multiple instances of the same chunk in the scene (unless there is additional things at play e.g. a script moving objects from the chunk into the main scene, then unloading the chunk, etc.)

If you are doing things like switching characters etc. it sounds like you are familiar with scripting and / or have a programmer on the team? If yes, it should be possible to figure out what is going on by checking where the requests to load / unload a chunk are coming from. 

Chunks are being loaded in as soon at least one loader puts a "reference" on it. A reference means that a loader says "hey I require this chunk". As long as there are still references on the chunk, it will remain loaded, if none are left, it can be unloaded. Could you please try to set a breakpoint on
SECTR_Chunk.AddReference()
SECTR_Chunk.RemoveReference()
to then see at the time the weird behavior happens, where all these constant requests to load and unload the Sector / Chunk are coming from in the call stack?
Additionally you could also take a peek at the trigger loader code in debugging, it is fairly simple. What it does is it checks for collisions, then puts a reference on all sectors / chunks in its list. When the collision ends, those references are being removed. If you debug the script and e.g. see that the collision trigger is triggered again and again, this might explain the weird behavior.

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