Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Your Computer
Oct 3, 2008




Grimey Drawer

TooMuchAbstraction posted:

I swear when I tried calling that it transitioned to the new scene automatically. What I thought would be available would be something that says "start loading this scene, let me know when you're done, then I call this other function to switch over to the new scene." So for example, while the player is looking at the level intro cutscene, I can start loading the level itself, but I won't transition to the level until the player clears the final dialog box.

Maybe I'm not understanding how to use it correctly.
I'm not gonna claim I understand how any of this works but I did it using some slightly modified code from https://docs.unity3d.com/ScriptReference/AsyncOperation-allowSceneActivation.html

code:
    public void FadeToLevel(int levelIndex) {
        levelToLoad = levelIndex;
        animator.SetTrigger("Fadeout");
        StartCoroutine(LoadScene());
    }

    public void OnFadeComplete() {
        finished = true;
    }

    IEnumerator LoadScene() {
        yield return null;

        AsyncOperation newLevel = SceneManager.LoadSceneAsync(levelToLoad);
        newLevel.allowSceneActivation = false;
        Debug.Log("loading new scene");
        while(!newLevel.isDone) {
            yield return null;

            if(finished && newLevel.progress >= 0.9f) {
                newLevel.allowSceneActivation = true;
            }
        }
    }
it feels like a hack which is why I'm a bit wary :v: The OnFadeComplete method is called from an Animator Behaviour (using the fade animation's OnStateExit) which also feels like there's gotta be a better way. Also doing it this way makes it stutter a little as it starts the coroutine, so I might just put the loading in the OnFadeComplete() method instead, which technically makes the loading a little longer since it doesn't start until the fadeout is complete but it's a bit smoother.

still racking my brains over the effect itself though

Adbot
ADBOT LOVES YOU

KillHour
Oct 28, 2007


For the effect I'd use a post process shader. Just make the UV scale over time.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Your Computer posted:

- A way to trigger the fade out animation, determine when the animation is done before loading the next scene

- Wait for the scene to fully load before triggering the fade in animation to avoid the stutter

Load the scene additively immediately if you can, so it starts loading during the animation. Then use the animation to kill some of the loading time.

Then just leave the screen black, and have a callback method

SceneManager.sceneLoaded += OnSceneLoaded;

void OnSceneLoaded(Scene scene, LoadSceneMode mode){ ... }

and do the fade-in animation trigger there

TooMuchAbstraction posted:

I wish I knew how to load a scene in Unity without immediately transitioning to it.

SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);

or

SceneManager.LoadSceneAsync(sceneName);

Well, that lets you load multiple scenes. You could disable everything on load and then enable them when you're ready to transition if you wanted to put it off?

https://docs.unity3d.com/ScriptReference/AsyncOperation-allowSceneActivation.html

This allows you to load a scene most of the way, have it stop and wait for you to tell it to finish. So that's even better!

quote:

When used in combination with LoadLevelAsync & LoadLevelAdditiveAsync it allows you to delay the actual activation of the Scene. (And unloading of the previous Scene).

When allowSceneActivation is set to false then progress is stopped at 0.9. The isDone is then maintained at false. When allowSceneActivation is set to true isDone can complete. While isDone is false, the AsyncOperation queue is stalled. For example, if a LoadSceneAsync.allowSceneActivation is set to false, and another AsyncOperation (e.g. SceneManager.UnloadSceneAsync ) is initialized, the last operation will not be called before the first allowSceneActivation is set to true.

Zaphod42 fucked around with this message at 17:21 on Oct 20, 2019

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Thanks, y'all. I'm gobsmacked that AFAICT that wasn't linked from LoadSceneAsync...nor was it referenced from the Google searches I did, that I noticed. Maybe that's my searching fail. :shrug: Any case, now I know!

Your Computer
Oct 3, 2008




Grimey Drawer

KillHour posted:

For the effect I'd use a post process shader. Just make the UV scale over time.
no real post-processing for me since I'm not using the scriptable render pipelines, so I'd have to do it with render textures which would screw up the other render texture post-processing I've been working on :v: I also don't just want to scale the UV over time, I want more control over the transition (as well as knowing when it's finished). Doing it with a shader still seems like a good idea though, but if I want to do stuff like rotation it gets a lot more complicated and less easy to animate :saddowns:

Your Computer
Oct 3, 2008




Grimey Drawer

Zaphod42 posted:

Load the scene additively immediately if you can, so it starts loading during the animation. Then use the animation to kill some of the loading time.

Then just leave the screen black, and have a callback method

SceneManager.sceneLoaded += OnSceneLoaded;
I'm not sure what the difference between just doing SceneManager.LoadSceneAsync or using the additive mode? I'll have to look into it. I actually tried using SceneManager.sceneLoaded before and it just called the method immediately upon loading rather than when it was finished loading, but that was before I knew about LoadSceneAsync so maybe I'll have to look into that too.

either way, I've got something that sorta works now at least
https://i.imgur.com/HySD4Fg.mp4

it's still not pretty but I tidied up some stuff. First of all I'm doing the fade with a shader (but still with animation clips controlling the shader values) and scaling the UVs, and it's rendered with a second camera

secondly I cut down the number of animations and scripts by just using the same animation twice (and running it forwards and backwards) and instead of adding more animation states and behaviours I'm just using one behavior on the fade out state checking if it has run its duration and then calling OnFadeComplete() to load the next scene. It's a start?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Honestly, that looks good! Definitely good enough that I'd move on to something else for now.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
I livestreamed modeling a ship, its bridges, the smokestack, and a couple of superstructure parts today. It was fun and productive, but also exhausting. Gotta be "on" all the time, no breaks, always talking about what you're doing.

https://twitter.com/byobattleship/status/1186059861072629760

al-azad
May 28, 2009



Sometimes I think about streaming my work but then I'm reminded it would be 5 minutes of productivity followed by 10 minutes of poo poo posting, looking up how to do a simple but rarely used task, and gawking at other peoples' art.

Synthbuttrange
May 6, 2007

Your Computer posted:

that's my bad for not making it clear - it's unnoticeable in the gif because that transition is manually animated :v: It's the other transitions (like going out of a crouch) that breaks. Here's an example that shows the issue in motion



rapidly crouching and uncrouching which makes Unity automatically blend between the idle/crouching animations

One way to do it without constraints is once you've got the animation you want, bake all animation frames.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
I've done all of three streams now, but I think the main thing is to have multiple tasks lined up for you to work on, so if one gets blocked (or, as in my very first stream, goes unexpectedly smoothly), you have something else to do. For this one I had six ships' worth of reference images to work from just in case somehow the modeling process took like ten minutes per ship instead of the 2+ hours it usually does.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
Save up quick and easy tasks for streams.

Your Computer
Oct 3, 2008




Grimey Drawer

Synthbuttrange posted:

One way to do it without constraints is once you've got the animation you want, bake all animation frames.
I've tried that but the problem isn't with the animations. It's when Unity blends between two different animations, like so:


without manually animating every transition (which itself brings problems since it can't account for where in the animations the transition happens) there doesn't seem to be a way around it, since all it's doing is going "here is the hand, here is where the hand wants to be, here is the quickest path" and without knowledge of constraints the quickest path is just a straight line :v: It seems like it's a non-issue though, unless Unity's constraint system is cursed or something. I just put in the same constraints I have in Blender (hand positions locked to the end of the arms, feet positions locked to the end of the legs) and everything looks and works fine now.

in other news I just learned about ScriptableObjects and now I want to refactor all my code

Just Andi Now
Nov 8, 2009


Your Computer posted:

in other news I just learned about ScriptableObjects and now I want to refactor all my code

I've been down this rabbit hole. There's a time and a place for them, and it's way too easy to accidentally use them for too many things.

Your Computer
Oct 3, 2008




Grimey Drawer

andipossess posted:

I've been down this rabbit hole. There's a time and a place for them, and it's way too easy to accidentally use them for too many things.
yeah that's fair :shobon: I saw the two talks that I'm sure everyone has already seen years ago about ScriptableObjects and the two things I'm most interested in that I feel like could really clean up my code is the event thing (for example, when the player touches a loading zone I could raise an event that could trigger different things like fading the screen out, loading the next level, disabling player input and playing a little sound effect, stuff I'm currently doing with some ungodly spaghetti code) and using them for settings and other data like that. I'm also curious about using them for what variables that aren't tied to a specific game object like the player HP example shown but maybe that's taking it a step too far

but basically anything to make things more modular and less hardcoded because right now my code's a mess and if I'm gonna start adding more functionality I need a better system :v:

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
As I understand it ScriptableObjects are primarily intended for structured but static (stays the same across play sessions) data. Trigger volumes would be a decent use -- you'd have the volume as a GameObject, with an attached script component that has a public WhatToDoWhenPlayerCollides ScriptableObject that has things like what scene to transition to or what cutscene to play.

For my game I'm using them to hold things like ship and part stats, so every model I make has a ScriptableObject that says e.g. "this is a ship, it has 100 HP" or "this is a gun, it fires hitscan bullets that deal 2 damage apiece, with .05 seconds between shots and it plays this sound effect when it fires".

Your Computer
Oct 3, 2008




Grimey Drawer

TooMuchAbstraction posted:

As I understand it ScriptableObjects are primarily intended for structured but static (stays the same across play sessions) data. Trigger volumes would be a decent use -- you'd have the volume as a GameObject, with an attached script component that has a public WhatToDoWhenPlayerCollides ScriptableObject that has things like what scene to transition to or what cutscene to play.

For my game I'm using them to hold things like ship and part stats, so every model I make has a ScriptableObject that says e.g. "this is a ship, it has 100 HP" or "this is a gun, it fires hitscan bullets that deal 2 damage apiece, with .05 seconds between shots and it plays this sound effect when it fires".
yeah, using them for data definitely seems like the primary intended use

I really like the example shown of using them for events the most though (about halfway down on this page) because it simplifies so many things. To go back to my loading zone example, right now my loading zone script has to find and call functions in the Player, the PlayerInput, the LevelChanger and anything else I feel like doing when stepping on it which is a bit of a hardcoded mess, but with events like that I can instead just have the loading zone raise a "time for loading, here's my data" event and the player, level changer etc. can be subscribed to that event and do their own thing. A lot less messy since the loading zone doesn't have to know about anything other than itself and its data (which could also be a ScriptableObject like you mention) and I don't have to reference any specific classes.

e: guess I'm kinda repeating myself but I'm very excited about this revelation :v: It just makes some things so much simpler for me but I guess I should ask, is there any downside to using this technique?

Your Computer fucked around with this message at 18:47 on Oct 21, 2019

Your Computer
Oct 3, 2008




Grimey Drawer
trying the above idea in practice

https://i.imgur.com/E6tieDB.mp4

each loading zone has a ScriptableObject asset containing the scene index and spawn point to warp to and an exit direction vector, and a ScriptableObject event that it raises when the player touches the zone which passes along the data. The player and level manager listen for the event and do their thing when it gets raised (player locks input and sets velocity to exit direction vector, level changer fades out and loads the scene and so on). Unless there's a fatal flaw in this concept I gotta say I like how it works!

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
Yeah I have ScriptableObjects to store all my Ingredients and cookable Foods, because they're just each a collection of constant variables.

This food has this name and this value and this effect, that food has this name and this other value and this other effect.

Then I can quickly plug them into different places in the game where those ingredients need to be given or used.

They can be used to make things more modular, but aren't really the only way. I do agree about being careful using them, like I just found out you can't serialize them.

Your Computer posted:

I really like the example shown of using them for events the most though (about halfway down on this page) because it simplifies so many things. To go back to my loading zone example, right now my loading zone script has to find and call functions in the Player, the PlayerInput, the LevelChanger and anything else I feel like doing when stepping on it which is a bit of a hardcoded mess, but with events like that I can instead just have the loading zone raise a "time for loading, here's my data" event and the player, level changer etc. can be subscribed to that event and do their own thing. A lot less messy since the loading zone doesn't have to know about anything other than itself and its data (which could also be a ScriptableObject like you mention) and I don't have to reference any specific classes.

e: guess I'm kinda repeating myself but I'm very excited about this revelation :v: It just makes some things so much simpler for me but I guess I should ask, is there any downside to using this technique?

Yeah, that's great and way more modular, but the real strength there isn't coming from the ScriptableObjects. That's design patterns!

https://sourcemaking.com/design_patterns/command

https://sourcemaking.com/design_patterns/observer

Design patterns are hot poo poo and will make your code much much cleaner and more maintainable. And you can use a ScriptableObject as your Command object, but the big win you're talking about here is really coming from using the design patterns.

The advantage of ScriptableObjects is that they're like prefabs, but they're not GameObjects. They're like little script instances that don't have all the overhead of a full GameObject prefab. At least, that's my understanding.

So, are there any downsides to Design Patterns? Heck no! That's just proper computer science style programming. Its just better, as long as you're using the right tool. There are a lot of design patterns, and it is possible to use one in the wrong situation which will simply clutter your code a bit, but for the most part they're just pure goodness.

As to the ScriptableObjects themselves, the only downside would be like I said earlier, you can't serialize them, and possibly other unknown limitations. But if you're just storing like a struct, some group of const game data, they're probably a good solution.

Zaphod42 fucked around with this message at 03:02 on Oct 22, 2019

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Zaphod42 posted:

They can be used to make things more modular, but aren't really the only way. I do agree about being careful using them, like I just found out you can't serialize them.

I mean, nothing's stopping you from writing your own public static WhateverObject Deserialize(string text) and a corresponding Serialize function. But it's up to you to call them in the right places.

But since a ScriptableObject is just a small pile of data, you'd probably be better off storing the object's name and then having a library that uses Resources.Load to retrieve the ScriptableObject. Of course this means putting all your SOs into a Resources directory.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

TooMuchAbstraction posted:

I mean, nothing's stopping you from writing your own public static WhateverObject Deserialize(string text) and a corresponding Serialize function. But it's up to you to call them in the right places.

But since a ScriptableObject is just a small pile of data, you'd probably be better off storing the object's name and then having a library that uses Resources.Load to retrieve the ScriptableObject. Of course this means putting all your SOs into a Resources directory.

Yeah that's what I came to a few pages ago. Right now I have a FoodLibrary gameObject that has a reference to all the ScriptableObjects and uses its lists to deserialize. Alternatively I could move them all to Resources and load them dynamically, may do that because this'll probably become untenable after awhile. IDK.

Its not a huge deal just, IDK. It seems like there should be some way to register the ScriptableObjects in the environment so you can automatically get a reference to one of them by name or inject the right one or something, that'd make this trivial. Or by some GUID or whatever.

Its just the whole thing exists to make using the editor easier, and this is kinda a downside. Its two steps forward, one step back.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Zaphod42 posted:

Its just the whole thing exists to make using the editor easier, and this is kinda a downside. Its two steps forward, one step back.

Yeah, I agree. The inability to introspect on assets that are not in a Resources folder is one of those baffling lack-of-capabilities in Unity. I'm sure there's some reason for it (maybe Unity omits things from the build if they aren't obviously used?) but it's pretty irritating sometimes.

Your Computer
Oct 3, 2008




Grimey Drawer
I'm a little confused.. are there different definitions of serializable? I thought that was like, one of the key strengths about ScriptableObjects (but also my understanding of serialization is really muddy)

Zaphod42 posted:

Yeah, that's great and way more modular, but the real strength there isn't coming from the ScriptableObjects. That's design patterns!

https://sourcemaking.com/design_patterns/command

https://sourcemaking.com/design_patterns/observer

Design patterns are hot poo poo and will make your code much much cleaner and more maintainable. And you can use a ScriptableObject as your Command object, but the big win you're talking about here is really coming from using the design patterns.
yeah, I recognize that. I've looked a little bit into it before but it was always really confusing. Delegates are kinda like that, right?

The neat thing that I love about using ScriptableObjects like this is that it doesn't require any changes in the code to make use of. If I want the player to listen for a certain event I don't have to modify the player script to subscribe to a particular method or anything like that, I just add an event listener component and drag in the ScriptableObject event that I want to listen to. Any other object in the scene can then reference that same ScriptableObject and raise the event whenever. It simplifies things massively and makes so much more intuitive sense to my brain :v:

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Your Computer posted:

I'm a little confused.. are there different definitions of serializable? I thought that was like, one of the key strengths about ScriptableObjects (but also my understanding of serialization is really muddy)

yeah, I recognize that. I've looked a little bit into it before but it was always really confusing. Delegates are kinda like that, right?

The neat thing that I love about using ScriptableObjects like this is that it doesn't require any changes in the code to make use of. If I want the player to listen for a certain event I don't have to modify the player script to subscribe to a particular method or anything like that, I just add an event listener component and drag in the ScriptableObject event that I want to listen to. Any other object in the scene can then reference that same ScriptableObject and raise the event whenever. It simplifies things massively and makes so much more intuitive sense to my brain :v:

I don't think so, serializable means you can write it to like, a stream of bits, and then read it back and re-create the object. ScriptableObjects, because they're meant to be like, const values, can't be serialized. The thing is generally, "why would you want to", because they're constant values.

But in my case, I have a player inventory which contains a variable amount of these ScriptableObjects, so I want to be able to store which you have currently. The easy thing would just be to serialize the inventory, but I can't do that, because these ScriptableObjects are special and const values that don't need to be saved.

Like Abstraction said, you can store the names, and since when you're trying to de-serialize the ScriptableObject, they're still the same as they always are, all you have to do is match which ScriptableObject to de-serialize to, by storing an ID or name instead. But that means you need to be able to look up all the ScriptableObjects to then pick using the ID, which is the problem I was describing. There's probably some better way to do it but :shrug:

Design Patterns can be real confusing in a void, and I often forget to use them myself. But practicing them makes you a better programmer, period. I read a design patterns book at work last year and it made my code better, along with Clean Code which is just good practices.

Delegates are like callbacks, or like function pointers. They can hold a reference to a method and then you can pass that as a variable, and then the person who gets the reference can call on the delegate without knowing what it is they're actually invoking. So they can totally be used for a command / messaging system, yeah.

The thing is, you could accomplish that same thing without ScriptableObjects, just having some Script Interface class, having things that expect that Interface as a reference, and then creating concrete classes that implement that Interface. And then everything else you just said you're doing works too, you just create the concrete class, plug it in as a reference to anything that needs to raise the event. ScriptableObjects aren't needed for that. But making them ScriptableObjects probably does make sense, as they're just lightweight little flags/handles being passed around.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
https://twitter.com/DevSpacePrez/status/1186475866534100993?s=20

Goats :3:

Who wants goat-cheese? Or grilled goat?

FuzzySlippers
Feb 6, 2009

ScriptableObjects are a huge improvement over any kind of Monobehavior abuse, but I've still seen plenty of awkward usages when plain old xml/json would be a lot simpler. Having a million SOs spread over your project you need to adjust for relational values is hell over having a single json to zip through. Like so much in Unity it seems amazing when you have a couple of something, but it becomes madness as your content grows.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

FuzzySlippers posted:

Like so much in Unity it seems amazing when you have a couple of something, but it becomes madness as your content grows.

You ain't just whistlin' dixie there buddy

Metos
Nov 25, 2005

Sup Ladies
In my current project that's at the 2 year mark I've basically done that, used to have scriptable objects for everything after seeing That Talk, and then as things grew and added more pieces, plus localisations properly handled instead of just thinking it would be easy to add in to the current system, it just got way easier to store everything is Json again.

A big difference that's added a tonne of ease of reuse in my current architecture is remembering that not everything has to be a monobehaviour. Making everything one was a habit I picked up when starting Unity stuff, but handling all my data in just serializable classes that can read from a file in resources has given me that freedom I thought I was getting from scriptable objects.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Mm, yeah, I should probably start moving at least some of my part/ship data into a CSV. I'm up to 59 ships/parts, and the thought of trying to manually update each of them / keep them in sync is starting to sound kind of dreadful.

FuzzySlippers
Feb 6, 2009

I'm gonna plug CastleDB again. It's a json editor that lets you edit your json like an excel sheet with support for colors, enums, and sprites. It was used in Dead Cells and I think its pretty great. Lets you have a human readable json file while also having access to a visual editor without any conversions or having to write a custom editor.

KillHour
Oct 28, 2007


This is what happens when I can't sleep.

https://www.youtube.com/watch?v=dKIbuqAymrs

...I think the flashing lights are messing with my circadian rhythm.

Your Computer
Oct 3, 2008




Grimey Drawer
thanks for the advice y'all

I've got some more newbie architecture questions now that I'm dealing with moving between scenes though, like what's the proper way of moving the player between scenes? At the moment I don't have anything set to DontDestroyOnLoad and just have a level changer and player in each scene but is this a case where you'd want to use it? Perhaps have the level changer stay between scenes and spawn the player prefab at the specified spawn point? as you can tell I've never gotten very far in any of my previous projects :v:

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

KillHour posted:

This is what happens when I can't sleep.

https://www.youtube.com/watch?v=dKIbuqAymrs

...I think the flashing lights are messing with my circadian rhythm.

Honestly I think the main thing you're missing now is a crowd of dancers. Maybe you can team up with that guy doing the art installation thing where your actions are recorded and re-played after a short delay to let the player make their own dance squad?

KillHour
Oct 28, 2007


No way I'm going through the effort of building networking infrastructure just for that. Believe me, there's still a LOT missing.

Fur20
Nov 14, 2007

すご▞い!
君は働か░い
フ▙▓ズなんだね!

KillHour posted:

No way I'm going through the effort of building networking infrastructure just for that. Believe me, there's still a LOT missing.

cmon it's not that bad just shunt hundreds of encoded byte sequences through a p2p connection

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

KillHour posted:

No way I'm going through the effort of building networking infrastructure just for that. Believe me, there's still a LOT missing.

That's the beauty of the recorder: it's all local and just builds up a bunch of echoes of the player's actions over time.

I mean, a networked dance party would be pretty cool, and I think would make a much better hook if you wanted to sell the thing, but it's not what I'm talking about.

KillHour
Oct 28, 2007


Oh you mean replaying the player. It's possible but you'd have to be in it for a long time build up a "crowd" and they wouldn't be actually dancing unless you strapped trackers to your legs and torso like a streamer. Probably easier just to have spawnable crowds. I honestly hate other people at concerts and wish I could have the whole place to myself so I haven't really thought about it.

Corbeau
Sep 13, 2010

Jack of All Trades
After two weeks of getting almost nothing done due to Life Happening, it feels very good to settle down and get some more progress on my game.

My ships can now not just aim, but also shoot! And the target-leading and gun convergence (and object pooling!) code all works in practice the way it's supposed to in theory.



Next is actually registering hits. :v:

FuzzySlippers
Feb 6, 2009

Your Computer posted:

thanks for the advice y'all

I've got some more newbie architecture questions now that I'm dealing with moving between scenes though, like what's the proper way of moving the player between scenes? At the moment I don't have anything set to DontDestroyOnLoad and just have a level changer and player in each scene but is this a case where you'd want to use it? Perhaps have the level changer stay between scenes and spawn the player prefab at the specified spawn point? as you can tell I've never gotten very far in any of my previous projects :v:

You are dragging your player prefab into every scene? That seems like a headache that'll develop bugs over time. I also wouldn't make your level changer a mono. It could easily be a plain c# class or a scriptableobject if you want it to hold Unity data (or both with the execution being in a plain class and it accepting a SO as a config).

One way that avoids some bugs or built up detritus is to hold onto nothing between levels. Serialize your important player info to a holder class, load destructively the new scene, then instantiate a new player prefab and when its done load in the serialized player data to configure it. That'll be a minor pain to implement but it'll avoid issues later.

Adbot
ADBOT LOVES YOU

Your Computer
Oct 3, 2008




Grimey Drawer

FuzzySlippers posted:

You are dragging your player prefab into every scene? That seems like a headache that'll develop bugs over time. I also wouldn't make your level changer a mono. It could easily be a plain c# class or a scriptableobject if you want it to hold Unity data (or both with the execution being in a plain class and it accepting a SO as a config).

One way that avoids some bugs or built up detritus is to hold onto nothing between levels. Serialize your important player info to a holder class, load destructively the new scene, then instantiate a new player prefab and when its done load in the serialized player data to configure it. That'll be a minor pain to implement but it'll avoid issues later.
yeah, you got it right. That sounds like exactly what I want to do, I just have no idea where to start :shobon:

It sounds like I want to serialize the things like player health etc. and also spawn location (currently the level changer gets this info but obviously can't use it since it isn't kept between scenes :v:), and then start the new scene with that info. Basically I need something to get some info from somewhere and then spawn the player and so on based on that when the scene loads, I just don't know how I'd go about doing it. I also need to find a good way to organize data like the spawn points since right now I'm just passing around an index and I haven't actually implemented any functionality anywhere that says "spawn point 0 is at this location in this level". I assume I need some sort of data structure per level containing these things but that's as far as I've gotten.

everything that has to do with architecture is basically new to me. I really like the idea that it should be possible to just plop into any level and test it though, which is why I've tried avoiding stuff like having a scene with singletons and all that jazz

Your Computer fucked around with this message at 22:24 on Oct 22, 2019

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply