Jump to content

Looking for some guidance - what is the best approach for this scenario?


Edmar

Recommended Posts

Hello there. 

I'm new to scene streaming, and I'm looking for some guidance on what could be the best approach to stream sections in my game main location: a tiny city in the middle of nowhere. Please, find attached a drawing of what the city will more or less look like.

Some houses and some hotel rooms will always be locked (the player can't enter), the remainder of them will have full interiors, with items the player will interact with, collect etc, as well, some npcs. 

I really have two questions here:

  • While on the hotel 2nd floor is pretty clear (main hall being a big sector, all other rooms small sectors and doors used as portals). What would be the best approach for the other houses? Make the streets as sectors and connect them with the houses through portals, or just stick a region loader on the player prefab and let it load those by distance.

And here is the trick one:

  •  Some of these houses/hotel rooms will be "locked" until mid-late game, and their interior can change according to some player actions. While simply having each room configuration on their own prefab/object on the hierarchy and just enabling/disabling or instantiating them accordingly seems an easy way out, I would like to know if Sectr could help me with that as well. Like would it be possible to have two sectors overlapping on the same position and load the necessary one programmatically or even choose which chunk will be loaded for that particular region?  

 

Thanks in advance!

 

EscapeRoom Puzzles.drawio.png

Edited by Edmar
Spelling
Link to comment
Share on other sites

On 12/14/2023 at 11:21 AM, Edmar said:

I really have two questions here:

  • While on the hotel 2nd floor is pretty clear (main hall being a big sector, all other rooms small sectors and doors used as portals). What would be the best approach for the other houses? Make the streets as sectors and connect them with the houses through portals, or just stick a region loader on the player prefab and let it load those by distance.

Yes, in the hotel sense, I would use sectr for this, one of the demo scenes shows this in action. 
Typically I use Sectr for open-world dungeons and interior stuff like this. 
Gaia Pro for World Streaming. 

However, going to your second question. 

There was a GDC talk about Firewatch you can probably still find on YouTube that they did something amazing with Sectr. 

They generated the chunks of both a land chunk with a building on it and then a burning land chunk with a burnt building on it, and at a certain point in the game when the "climax" happens they replaced all the beautiful chunks with the burnt and destruction chunks. I would imagine with this you could do the same thing. Now sadly we don't support this out of the box and I am not entirely sure how they did it. However, they tied into the code where the chunks are being loaded. Then setting some parameters around this. 

I would go the same approach as that maybe? 
Hoped that helped. 

Link to comment
Share on other sites

16 hours ago, Bryan said:

Gaia Pro for World Streaming. 

I thought about that, but the city itself will be only around 1km2. I'll have locations around where I'm planning on using Gaia Pro to load/unload

 

16 hours ago, Bryan said:

There was a GDC talk about Firewatch you can probably still find on YouTube that they did something amazing with Sectr. 

They generated the chunks of both a land chunk with a building on it and then a burning land chunk with a burnt building on it, and at a certain point in the game when the "climax" happens they replaced all the beautiful chunks with the burnt and destruction chunks. I would imagine with this you could do the same thing. Now sadly we don't support this out of the box and I am not entirely sure how they did it. However, they tied into the code where the chunks are being loaded. Then setting some parameters around this. 

I'll have a look thanks!. 

What I've been experimenting with for now is creating the rooms on the same position and different parents (each one with a sector on it), then I've created a custom trigger loader that loads the sector according to a flag that I have in my save file, I guess I can use similar logic to other types of loaders as well, but I'll check out what the guys on Firewatch did. 

My custom trigger loader:

using StarTravellers.SaveSystem;
using StarTravellers.SaveSystem.Data.Modules;
using System.Collections.Generic;
using UnityEngine;

public class ConditionalTriggerLoader : SECTR_Loader
{
    [System.Serializable]
    public class Condition
    {
        [field: SerializeField] public string FlagName { get; set; }
        [field: SerializeField] public SECTR_Sector Sector { get; set; }
    }

    [SerializeField, Tooltip("Conditions are evaluated following the list order")] private List<Condition> _conditionList = new();

    private SECTR_Chunk _currentChunk;
    private Variables _saveVariables;

    private void Start()
    {
        _saveVariables = SaveDataManager.Instance.SaveFile.Module<Variables>();
    }
    private void OnDisable()
    {
        UnloadActive();
    }

    private void OnTriggerEnter(Collider other)
    {
        LoadActive();
    }

    private void OnTriggerExit(Collider other)
    {
        UnloadActive();
    }

    public override string ToString()
    {
        return "Conditional Trigger Loader";
    }


    public override bool Loaded => _currentChunk && _currentChunk.IsLoaded();

    private void LoadActive()
    {
        var activeCondition = GetActiveCondition();
        if (activeCondition != null)
        {
            var sector = activeCondition.Sector;
            if (sector)
            {
                var chunk = sector.GetComponent<SECTR_Chunk>();
                if (chunk)
                {
                    chunk.AddReference();
                    _currentChunk = chunk;
                }
            }
        }
    }

    private void UnloadActive()
    {
        if (_currentChunk != null)
        {
            _currentChunk.RemoveReference();
            _currentChunk = null;
        }
    }

    private Condition GetActiveCondition()
    {
        // Evaluate last condition active
        Condition lastEnabledCondition = null;
        for (var i = 0; i < _conditionList.Count; i++)
        {
            var condition = _conditionList[i];

            // Empty flag means default condition
            if (string.IsNullOrWhiteSpace(condition.FlagName) || _saveVariables.ContainsKey(condition.FlagName))
            {
                lastEnabledCondition = condition;
            }
        }

        return lastEnabledCondition;
    }
}

 

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