#Can you walk me through how you have

1 messages Β· Page 1 of 1 (latest)

naive vessel
#

NVM i got it @nova idol

#

alrighty..

#

what kind of game are u making?

nova idol
#

It's a puzzle platformer similar to Mario vs Donkey Kong

naive vessel
#

do u know how to load scenes additively?

nova idol
#

Yes, that is already set up

naive vessel
#

alrighty..

#

im opening my project..

#

ill take some screenshots and comment on some things..

#

then u can ask w/e u need

nova idol
#

Thank you very much

naive vessel
#

(im still a newb btw)

#

i been learning about 3 years.. and i still feel like i dont know anything 🀣

nova idol
#

lol I know how you feel

naive vessel
#

Alright..
1 - I have a scene called BootLoader
this scene has almost everything I need thru-out the entire game.. it includes

  • my cameras
  • my player
  • the pause menu
  • the inventory
  • the UI and so on...
    2 - when my game begins I load save data first (this is just stuff like the volume, the field of view, graphics settings etc..
    3 - I then use that data to populate everything..
  • it goes into the menus to display to the user
  • it goes into the GameManager, etc..
    4 - When we press Play The first scene (Level1) loads in along side the BootLoader..
    ( when the game begins the player is enabled, the ui is enabled, the cameras are enabled)...

for the logic part of it.. (you're probably not gonna like this.. but the GameManager is a singleton.. it has a reference to a
ReferenceManager also in the BootLoader scene

the reference manager has references to everything... the player, the data, the levels, the inventory, and it also has references to other systems (the audiomanager for example)

this way I don't need abunch of singletons (technically I only need the one)... when I need to play an audioclip for example it ends up looking like

GameManager.instance.AudioManager.PlayClip(1); or something similar..

Since the bootloader loads in first.. and can't load the first level w/o all the references being valid and assigned.. I know theres no issue..

When we go to level2 this is what happens..

  • The Level1 becomes completed..
  • The GameManager/BootLoader gets told that we're now on Level2and it then saves that data .. Unloads Level1
    Loads in Level2 (resets the players position to the starting position in that level, etc)

very rarely.. do i need to grab references at runtime...
BUT if I do.. after the scene is loaded I search using Find() or w/e bad method there is and I grab those before the game actually begins (like when it unpauses)

#

now... if theres anything specific.. u wanna know.. or any code u'd like to see im happy to try to help

#

for validation I have a Game Initialization and a Scene Initialization.. these are custom set up.. and look for certain things in the next scene being loaded... if it can't find a certain thing..
for example: say my Enemies object was missing.. well it'd fire off an error in my Loading Screen telling me..

( its just a simple null check ).. and by checking these piece by piece i can have a Psuedo-loading screen..

nova idol
#

I appreciate you taking the time to write this up and record the videos. I guess singletons are pretty much unavoidable huh. So it sounds like the GameManager is in the BootLoader? Is that on the GAME_X object?

naive vessel
#

yes

#

my reference manager is the one im least happy with.. b/c every scene may have its own global volume (post processing) Light Manager etc..

#

soo for it I grab and initialize all this stuff at runtime after the scene is loaded in..

#

soo.. its my game/scene initalization (the loading screens and stuff) that assign all the stuff to the reference manager.. (and since its coupled to the GameManager singleton i can just access it from anywhere..

#

I personally dont see anything wrong w/ singletons.. (just dont abuse them..)
like i've seen some people learn that they exist... and they'll make every single script a singleton... that way they dont have to worry about references...

nova idol
#

Yeah I suppose only having one is probably the best way to use them.

naive vessel
#
        // Load Data Into GameManager
        LoadGameStats();
        LoadGameSettings();
        LoadChapter();
        LoadPlayerTransform();```
#

I'll only do this once at the beginning of every level..

#

soo the Find() methods.. arent soo terrible.. since they only happen once.. and then cache it all to use later

#

i got a bit of refactoring to do myself.. like.. my HealthCanvas... theres no reason it can't be in my BootLoader scene..

#

i guess i just overlooked it.. or coded too long that day πŸ˜…

#

but anyway imma refactor some of this now that im looking at it..
if u have any more questions or anything just Let me know..
good luck πŸ€

nova idol
#

Thanks again!

naive vessel
#

No problem..
i guess the key take-a-way from this conversation is..
Persistent scenes and Additive loading is a really good way to keep ur project all organized and easily accessible.. versus the alternative of.. adding things to a Dont Destroy On Load object or something.. just to keep it around..

#

if u plan ahead and know what Main systems ur games gonna run on.. its smarter imo to have all that stuff nested in a persistent scene and control everything thru-out the entire gameloop

naive vessel
nova idol
#

Makes sense

naive vessel
#

its also how i name my singleton instances..
instead of GameManager.instance.DoSomething();
its GameManager.X.DoSomething();

#

same w/ the rest of my project

#

some ppl hate it.. others dont mind it..

#

haven't ever gotten a positive reaction to it.. soo may not be something to copy lmao

nova idol
#

lol

naive vessel
#

its all about that "use names that make sense"

#

"if im reading that code how am i supposed to know that X means blabla"

#

there we go.. πŸ˜‰

nova idol
#

It does make every place that uses it less characters to type, but yeah I can see why people would not like it

naive vessel
#

if u get a prototype live anywhere let me know.. i'd like to see what u come up with

nova idol
#

I'm sure it'll be a while before that but I appreciate it!

shell fiber
#

I believe you can use a static class instead of a singleton.

naive vessel
#

tomato tomato in this case

#

i've heard "singleton" used interchangeably here in Unity

#

to me its a static class but w/ some fore-thought

shell fiber
naive vessel
#
public static Singleton Instance { get; private set; }

private void Awake() 
{ 
    // If there is an instance, and it's not me, delete myself.
    
    if (Instance != null && Instance != this) 
    { 
        Destroy(this); 
    } 
    else 
    { 
        Instance = this; 
    } 
}``` in their example they do some fool-proofing in teh Awake
#

I on the other hand πŸ˜…

#

since im not creating it at runtime.. and its attached to a gameobject that only exists in the Boot Scene i don't worry much about the null check and Destroy() methods

#

this is the singleton I use most often in my prototypes

#

having a Generic laying around allows me to just use : Singleton<ClassName> instead of Monobehaviour

#

and tada... Singleton πŸͺ„