|
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. code:
still racking my brains over the effect itself though
|
# ? Oct 20, 2019 16:41 |
|
|
# ? May 8, 2024 21:20 |
|
For the effect I'd use a post process shader. Just make the UV scale over time.
|
# ? Oct 20, 2019 16:46 |
|
Your Computer posted:- A way to trigger the fade out animation, determine when the animation is done before loading the next scene 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). Zaphod42 fucked around with this message at 17:21 on Oct 20, 2019 |
# ? Oct 20, 2019 17:15 |
|
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. Any case, now I know!
|
# ? Oct 20, 2019 17:24 |
|
KillHour posted:For the effect I'd use a post process shader. Just make the UV scale over time.
|
# ? Oct 20, 2019 17:28 |
|
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. 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?
|
# ? Oct 20, 2019 18:30 |
|
Honestly, that looks good! Definitely good enough that I'd move on to something else for now.
|
# ? Oct 20, 2019 19:12 |
|
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
|
# ? Oct 21, 2019 01:09 |
|
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.
|
# ? Oct 21, 2019 01:40 |
|
Your Computer posted:that's my bad for not making it clear - it's unnoticeable in the gif because that transition is manually animated It's the other transitions (like going out of a crouch) that breaks. Here's an example that shows the issue in motion One way to do it without constraints is once you've got the animation you want, bake all animation frames.
|
# ? Oct 21, 2019 01:58 |
|
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.
|
# ? Oct 21, 2019 02:09 |
|
Save up quick and easy tasks for streams.
|
# ? Oct 21, 2019 04:21 |
|
Synthbuttrange posted:One way to do it without constraints is once you've got the animation you want, bake all animation frames. 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 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
|
# ? Oct 21, 2019 13:07 |
|
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.
|
# ? Oct 21, 2019 17:17 |
|
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. 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
|
# ? Oct 21, 2019 18:07 |
|
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".
|
# ? Oct 21, 2019 18:13 |
|
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. 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 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 |
# ? Oct 21, 2019 18:40 |
|
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!
|
# ? Oct 22, 2019 02:45 |
|
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. 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 |
# ? Oct 22, 2019 02:56 |
|
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.
|
# ? Oct 22, 2019 03:02 |
|
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. 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.
|
# ? Oct 22, 2019 03:05 |
|
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.
|
# ? Oct 22, 2019 03:09 |
|
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! 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
|
# ? Oct 22, 2019 03:23 |
|
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) 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 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.
|
# ? Oct 22, 2019 04:01 |
|
https://twitter.com/DevSpacePrez/status/1186475866534100993?s=20 Goats Who wants goat-cheese? Or grilled goat?
|
# ? Oct 22, 2019 04:02 |
|
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.
|
# ? Oct 22, 2019 04:14 |
|
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
|
# ? Oct 22, 2019 04:28 |
|
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.
|
# ? Oct 22, 2019 04:32 |
|
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.
|
# ? Oct 22, 2019 04:34 |
|
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.
|
# ? Oct 22, 2019 04:52 |
|
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.
|
# ? Oct 22, 2019 08:52 |
|
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
|
# ? Oct 22, 2019 13:13 |
|
KillHour posted:This is what happens when I can't sleep. 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?
|
# ? Oct 22, 2019 14:35 |
|
No way I'm going through the effort of building networking infrastructure just for that. Believe me, there's still a LOT missing.
|
# ? Oct 22, 2019 14:48 |
|
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
|
# ? Oct 22, 2019 14:53 |
|
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.
|
# ? Oct 22, 2019 15:42 |
|
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.
|
# ? Oct 22, 2019 16:53 |
|
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.
|
# ? Oct 22, 2019 19:20 |
|
Your Computer posted:thanks for the advice y'all 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.
|
# ? Oct 22, 2019 21:10 |
|
|
# ? May 8, 2024 21:20 |
|
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). 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 ), 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 |
# ? Oct 22, 2019 21:35 |