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
Those are both good ideas, but unfortunately I think any disconnected movement like that would be very difficult without root motion.

Adbot
ADBOT LOVES YOU

Your Computer
Oct 3, 2008




Grimey Drawer

LordSaturn posted:

ghostie coming out of nowhere doesn't look weird to me at all. it's... a ghost. they do that.

Zaphod42 posted:

It is a ghost though! I think it looks fine. Could stick with that for now and come back and polish it later if you feel like it.
that's true, I suppose. Want to keep the backpack though, not because BK did it or anything but because I think it's cute :ghost:

I did a second attempt at a direct jump->parachute animation using some stretch to make it more obvious that ghostie is coming out of the backpack. Still needs work but maybe it's better?


Omi no Kami posted:

What if the ghost floats on your shoulder by default and you give him two extra animations: disappear in a poof of smoke (or particles or whatever), and reappear in a puff of smoke? Then you can completely decouple your shoulder buddy from your animations, and just have him blink out of existence and reappear as a parachute/surfboard/tennis racket or whatever (which is a completely independent asset, since the shoulder ghost will just be deactivated until he needs to come back)?
skelly doesn't really have much in the way of shoulders, so I think the ghost would have to be very tiny to fit on there :v: I like the idea of model switching though, which I'll probably make use of in some form. I'd imagine the difficult part with something like that is getting any animations to sync up, although if ghostie's gonna be static (like your examples) then that's not a problem I suppose.

Your Computer fucked around with this message at 12:31 on Oct 12, 2019

Your Computer
Oct 3, 2008




Grimey Drawer

been working on foliage billboards, a thing I'm gonna need a whole lot of. I love this workflow :toot:



Imhotep posted:

I'm also messing with Blender, and 3DS Max plus Unity at the same time is a bit overwhelming. You said at one point you only used Unity and Polybrush and ProBuilder and kind of didn't need Blender? But I see that you're also using 3DS Max (which I just got because of your post), which is funny because even Blender is difficult for me and it certainly doesnt seem like it looks 'too good' when I'm using Polybrush on a plane or whatever to make a simple terrain. But it's also just overwhelming in general for me as I'm not only new to game design stuff, but even the most basic visual art stuff as well, so I'm trying to focus on Unity and just use Max or Blender for simple modeling stuff, copying methods from tutorials to make super simple stuff.
sorry, I was just saying that it was almost like I didn't need Blender but I was just being cheeky. I still use it to model and rig/animate and I think that doing everything in Unity would be difficult if not impossible. Polybrush and ProBuilder are very good for prototyping and doing certain stuff (better vertex painting support than Blender) and I think using them along with a proper 3D modeling program like Blender is the way to go.

Learning this sort of stuff is always going to be very overwhelming in the beginning but once you get over the initial hump it's a lot of fun! I would suggest focusing on Blender 2.8 and look at any tutorials for that specifically. The only thing I use 3DS Max for at the moment is doing those prerendered images (which in fairness is a big part of this project) and the reason is simply that the materials and renderer out of the box are really outdated and perfect for the look I'm going for :v: Blender by default has a much more modern pipeline which is great if you aren't specifically trying to capture that 90s prerendered look. For a comparison, here's what the above plant looks like if I just plop it into Blender

It still doesn't look good, but it lacks that specific look with the harsh shadows, phong shading and bump mapping that is emblematic of ye olde prerender. Like I said, if you aren't specifically trying to capture that look then I would just go with Blender 2.8 and start learning how to use it. Learning multiple 3D modeling programs can be very difficult, as they all do very basic things very differently (including just moving the camera around) and all of the basic navigation skills and keyboard shortcuts will be different in each, so I would focus on one to start with.

al-azad posted:

One is 1024 and one is 512. The 1024 one is 3mb while the 512 one is 800kb. Go with the lowest fidelity that still looks good.
this is honestly something I wish modern game developers would care more about. It has been a trend for some time now to have max texture resolution at all times and we end up with games taking over a hundred GB because it's filled with useless stuff like 4K eyeball textures.

Your Computer
Oct 3, 2008




Grimey Drawer

Imhotep posted:

UM YES, THE 3DS MAX VERSION IS EXACTLY THE LOOK I WANT. Sorry, but yeah, I had no idea the difference was that drastic, and like you and I were discussing 50 pages ago, that sort of Nintendo 64 promo art look is so cool, and is literally what I've been wanting to do since I my first failed attempt at learning Unity/Unreal. This attempt is the first one that I've actually downloaded Blender/3DS Max/Maya, but Blender tutorials always confused me with it's unusual mouse and UI configurations, but maybe that's just every program.
Keep in mind that this is what the model looks like through the 3DS Max scanline renderer and isn't representative of what the model would look like if you were going to use it in a game engine like Unity. It's not easy getting that prerendered look in realtime and you would probably have to make/use custom shaders. What program you use to make the 3D model in is generally irrelevant in game development since the model itself is (essentially) just a collection of points in space, and how the model appears ingame will depend on the shaders you're using in the game engine. In Unity using the Standard Shader, it would look more like the Blender picture than the 3DS Max one, FWIW.

If the Blender stuff seems unusual, are you sure you're looking up tutorials for Blender 2.8? The program changed massively very recently and before 2.8 the interface and navigation was very different, so make sure you're looking at recent tutorials and not old ones.

Imhotep posted:

So, you think I should just set aside Unity while I learn how to use Blender/3DS Max? Also, it's really interesting how Blender seemingly can't achieve that look, like, I don't know, I guess it's just my total lack of experience with visual art in general, but it's bizarre to me that that's not easily achievable in Blender, let alone maybe even too difficult to achieve that it's not worth attempting.
If you want to focus on learning 3D modeling before you move on to learning how to make a game then sure, but I'm pretty sure there are several people in this thread who are learning both! I would however pick either Blender or 3DS Max to focus on for learning 3D modeling, since navigation and hotkeys are different between the two and learning both simultaneously would make an already slow process even slower. Since Blender is free while 3DS Max costs $200 per month I would highly recommend Blender :v: Don't let the price fool you, Blender 2.8 is an amazing piece of software and more than enough for this sort of work.

As for the second point I'm not confident saying it's too difficult to achieve or anything (I'm still pretty new to Blender myself!), especially considering how extensible Blender is. It's not easy to explain in a few words, but the reason is basically because Blender 2.8 uses shaders that are physically based (i.e. light interacts in a physically realistic way) while the default shaders in 3DS Max are using old "good enough" calculations that go back to the 70s. Physically based rendering (PBR) is a pretty big deal for anything that's even remotely trying to go for realism and it's what you see in just about every modern game, from Bloodborne to Super Mario Odyssey, and is what the Unity Standard Shader is using too, which means that for most users your model look pretty much the same in Blender and in Unity.

I'm sorry if I'm blabbing on, it's a very big topic and I'm not sure which parts you know and which parts you don't :shobon:

Your Computer
Oct 3, 2008




Grimey Drawer

Lanth posted:

I've been itching to get something working and having something more or less worthwhile to share for a while now, and since I had some downtime the last couple of weeks due to some health issues, I decided to try my hand at Unity and Visual Scripting again (tried GameFlow two years ago but didn't get very far, got Bolt now and can very much recommend it if you're useless when it comes to scripting and programming like me).


It's adorable and I love it! It's also already looking a lot more like an actual game than what I have so far :ghost: Did you model the skeleton with ProBuilder? Speaking of visual scripting, it's something I've wanted to give a try and I got Playmaker with the Humble Bundle (also apparently Unity is getting its own integrated visual scripting sometime?) but ironically it's a bit overwhelming for me because I have zero experience with it compared to just programming, so I don't even know where I'd start.


anyway, I'm working on trying to make my first level so that I have something to run around in and test stuff on. It's hard and I don't have anything to post yet :v: I still haven't figured out a good workflow since both Blender and ProBuilder have their pros and cons. ProBuilder is great for getting a sense of proper scale and seeing everything exactly as it's gonna be in the game, but it has some downsides like UV mapping being a pain compared to Blender. It's also missing some of the tools I use the most when modelling, like target welding. OTOH using Blender is great for quickly making stuff exactly as I want it to be, but much harder to judge heights and distances in so stuff tends to end up a bit out of proportion and needs to be tweaked a bunch afterwards. Both have some weird interactions with Polybrush (which I feared) so it seems like I'm gonna have to wait with the vertex painting and texture blending until I'm done with the geometry, which is a shame. I'm sure I'll figure out a good flow eventually though!


OC do not steal (obviously not something that's gonna be in the game, I just couldn't sleep yesterday and thought it would be funny)

Your Computer
Oct 3, 2008




Grimey Drawer
still working on putting together a little zone to test things in, it's a lot of effort!

due to how Polybrush works it seems like I gotta finalize everything before I can start coloring, which is really annoying (tweaking the model basically undoes any painting I've done) so I haven't gotten around to painting stuff yet, but here's a corner of the jungle so I have something to show off at least:


megane posted:

I know how it's supposed to be pronounced, but I can't help but hear it like a Spanish word: bo NEH ho, to rhyme with conejo.

Las Aventuras del Bonejo.
:allears:

Your Computer
Oct 3, 2008




Grimey Drawer

TooMuchAbstraction posted:

Looking good! Are those purple flowers billboards?
yeah! I posted about them in my last post, but I've been doing a bunch and I probably still need to do a bunch more




a cyberpunk goose posted:

I'm sure you're digging into this already or it's been brought up, but going nuts with vertex coloring will really sell the n64 aesthetic
oh for sure, that's why I mentioned it! In fact it was one of the key reasons why I rolled my own shader to begin with :v:

Your Computer
Oct 3, 2008




Grimey Drawer
just please do not hardcode anything to tilde

it's something US developers keep doing and it's endlessly frustrating because a lot of EU QWERTY keyboards don't have tilde in the same place as US QWERTY keyboards and that sometimes makes a menu or input functionally inaccessible unless the user changes the system language input in the OS


(see if you can spot the tilde)

in some games/software this is a non-issue since it's just tied to the key (i.e. whatever's above tab) and not the input but it's still something I see way too often

Your Computer
Oct 3, 2008




Grimey Drawer

The Fool posted:

Is that Ctrl-Alt-\ ?


e: because even on us keyboards the tilde key isn't actually the tidle key, it's the backtick key and tilde is Shift-backtick
it's AltGr-¨ but the ¨/^/~ key is an accent key so just inputting it does nothing until you make a second input (so you can write ä, â, ã etc.) which means that to get ~ you need to input AltGr-¨ followed by space, breaking anything that expects just a '~' input

for that matter, Shift-backtick is also an accent key for writing characters like à and á :v:

floofyscorp posted:

On my keyboard layout the 'tilde'/backtick key is meant to be used for inputting accented characters, so it doesn't actually do anything on its own and this makes activating/deactivating dev consoles that are hardcoded to that input to be nigh-impossible to use.
so even hardcoding it to the key and not the input isn't enough, then. Jeez!

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

Your Computer
Oct 3, 2008




Grimey Drawer

baby puzzle posted:

what's the snakey in the upper left? because maybe I can use that or tilde.

e: i think i'm listening for the key but I'm not sure.
just pressing the button it's actually '|' and not § (§ is Shift-|)

that said, what symbol is on that button varies from country to country a lot (check out https://en.wikipedia.org/wiki/QWERTY#Diacritical_marks_and_international_variants for just how many variations there are) so I wouldn't bind anything to a specific symbol

Peewi posted:

I don't know anything about how to implement it, but there are some games that will show the localized key name for the user's keyboard layout and I think that's pretty nice.
yeah, that would be nice (although I'm not sure I've ever seen it). I'm just used to seeing "press ~" and my mind goes "ah yes, the | key" :v:

Your Computer
Oct 3, 2008




Grimey Drawer
so I had a bit of a galaxy brain moment as I was trying to figure out how to give the impression of dynamic shadows without using shadow mapping

I am already faking shadows in the environment by painting them on with vertex colors, right? ....so what if I simply use that information and darken the player model based on the vertex colors they're standing on? Walking into a dark cave or the shadow of a tall object would give the impression that they're casting their shadows onto the player! :pseudo:


It took me all day but... it seems to be working?
https://i.imgur.com/Xyu1saD.mp4

I threw the script into the level I'm working on and to my surprise it still seems to be working :woop:
https://i.imgur.com/VmsQA7i.mp4

it still needs some things ironed out and the code is.... not pretty, but I still can't believe I got it working. I feel like there has to be a better way of doing it though because right now the code is kinda bonkers and I just did whatever I felt like could work :v: The script starts by calculating the positions of all the triangles in the level geometry by averaging their vertices and then uses that whenever the player moves to find the triangle the player is closest to (this is one of the things I need to fix since it doesn't actually consider what you're standing on, only closest to). Then in order to shade the player smoothly it takes the vertex colors of the three tris and the player's position within the triangle and interpolates them using barycentric coordinates (that one took a while to figure out, I've never even heard of that before!) before using that information to change a variable in the player's shader. I said it was bonkers :pram:

Your Computer
Oct 3, 2008




Grimey Drawer

KillHour posted:

The way you did it actually seems fairly reasonable, tbh. It looks great.

Closest is probably what you want, but if you really want standing on, you could do a raycast down. Either one could give weird results, especially when jumping/falling.
thanks :3:

The plan is to do a raycast down since I always want it to look at what's underneath me, yeah. That said, I need a new method of finding the nearest tri too since right now it produces some weird result even when I'm measuring from ground level:


sometimes it correctly picks the tri I'm standing on, sometimes if I'm close enough to a wall it picks that as the nearest tri and in some specific situations it picks a tri that I'm not even standing on!

In addition to getting a more accurate nearest tri and raycasting downwards, I could also filter the list of tris based on face normal (and exclude everything that isn't within -/+ X degrees of "up") or simply make the ground a separate mesh to cut down on the amount of tris checked significantly since I don't plan on getting shadow info from anything that the player can't stand on.

also, it shouldn't be a surprise at this point but I did some digging (which is to say I discovered romhacking) and you know who else figured out this trick over 20 years ago? I really am just rediscovering every old technique aren't I :cripes:

Your Computer
Oct 3, 2008




Grimey Drawer
already know about the channel and love that sort of stuff :allears: One of my favorite youtube channels is Retro Game Mechanics Explained which goes into crazy detail and has some impressive visualization to boot.


as I was heading to bed thinking about raycasts I was wondering if you could just get the triangle index directly from that and avoid any sort of manual sorting through tris, and wouldn't you know it there's literally a property just called RaycastHit.triangleIndex. The catch is that it looks at the mesh in the MeshCollider and not the mesh in the MeshFilter, but in my case those two meshes are the same for the level geometry and it seems to work just fine using the sharedMesh property? What I want to know is whether I can always expect the triangle indices to be the same for MeshCollider.sharedMesh and MeshFilter.sharedMesh if they're sharing a mesh. On the surface it sounds like an obvious yes, but I figure it's worth asking in case anyone knows :v:

seems to be working beautifully though and slots in just fine with the code I already have

Your Computer
Oct 3, 2008




Grimey Drawer

TooMuchAbstraction posted:

If they're literally using the same mesh, then they should have the same indices. If it's two distinct copies that happen to be identical, then I don't know. If it ever breaks down on you, what I'd do is have a once-per-scene process run that maps triangles in the collider mesh to triangles in the render mesh based on their vertex positions.

Looking good by the way!
oh yeah, that's a good idea! They are using literally the exact same mesh asset so hopefully I don't run into any trouble, but it's good to know that I have a solution if it happens.

I did some more work on it today and I think just about everything is working as I want it to now - I added some lerping so there's a tiny transition period to avoid abrupt color changes or flickering when going between contrasting triangles:


and also implemented a check for the face normal angle so it ignores anything the player can't stand on (might tweak the exact angle though, mostly I want to avoid it looking at walls):


also fixed a bunch of tiny bugs, like making sure I'm only reading from the level geometry :v: Had a nice bug when I stepped on an object and the color freaked out because it was mapping a triangle from the object I was standing on to the level geometry. Oops! I also made it so the raycast is pretty short, that way I can jump between platforms and such and it keeps the color of the last triangle I was standing on rather than whatever's down on the ground below.
:okpos: :okpos: :okpos:

Your Computer
Oct 3, 2008




Grimey Drawer
today I worked on implementing velocity smoothing and a first try at skidding!

https://i.imgur.com/mVTXiK1.mp4
(don't worry, I turned the smoothing way up for testing and I swear I'm not gonna have ice physics by default)

still a lot to be tweaked about the animation and particle effect, and there are some more things I want to do as well (like a little bit of running in place when you go from idle to full run, like in Mario 64) but I'm pretty happy that I got the general idea right. One thing I gotta figure out is making the code that turns the player around happen simultaneously with the skid, because right now it's off by a single frame and it shows :v: I tried bodging a solution by waiting to turn around for a frame but that just makes the skid sometimes happen the wrong way for a single frame. Maybe I can do the transition to skidding manually and then let the Animator take it from there.

Lanth posted:

Feast your eyes on the most beautiful menu ever:



Also, now that I see it in motion, I really like the signs over the ghosts heads!
This is starting to become colorful. I could probably animate the question/exclamation marks themselves at some point, but there's more important stuff for now.
it's great! :ghost: I kinda miss the light-up ghosts though. A combination maybe? As for animating the marks you could just give them a very simple bobbing up and down animation that loops, I think it would make everything a bit more lively.

looking wonderful though :spooky:

Your Computer
Oct 3, 2008




Grimey Drawer

TooMuchAbstraction posted:

But if I set the alpha channel based on the mask alpha, then nothing happens! That is, the corners are not masked out.
shot in the dark here but did you remember to set the rendering mode to cutout? :v:


KillHour posted:

I think it would look way better without rounded corners, actually.

While we're on the subject of graphics, you can't have a rave without an awesome volumetric light show!





I'll make them do more interesting stuff tomorrow.
I've never messed around with volumetric lighting before but drat that looks impressive

e:

Your Computer posted:

Maybe I can do the transition to skidding manually and then let the Animator take it from there.
you know, sometimes the easiest solution really is the best one and this worked like a charm :v: I know I went through and discovered all of this stuff before with the jelly project but it's a bit of a shame how the Animator can sometimes be a little unreliable. I'm wondering how I'm gonna handle the different player moves.

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

Your Computer
Oct 3, 2008




Grimey Drawer
crouching!



I've ran into a problem though, or rather, the problem is starting to become too obvious. I rigged the character with IK in Blender and it uses constraints to keep everything in place, but Unity doesn't care about those constraints so when it does its automatic blending between animations it rips the limbs apart like so:


"my hands :stare:"

as I was writing this post I googled "Unity constraints" and found that Unity does have its own constraint system which.... seems like it could solve it?

(position constraint on left hand, nothing on right hand)

is this the right approach or will I run into trouble doing it this way? To be clear I put a position constraint on the bones (heh) themselves, as in the empty transforms. In this case that's a position constraint from Hand_L to Arm2_L_end, the same constraint that I use on the rig in Blender.

Your Computer
Oct 3, 2008




Grimey Drawer

IronicDongz posted:

I actually think that at the speed shown in that gif, that issue is pretty much not noticeable.

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

Your Computer
Oct 3, 2008




Grimey Drawer
so here's something I'm surprised I can't find a good answer to - scene transitions, how do you do 'em properly?

all I want is something that looks kinda like this, but in a way that scales and doesn't lag terribly:
https://i.imgur.com/Vm1NYpB.mp4

as you can see it lags on first load and on loading the bigger scene with things in it. It also doesn't scale with different resolutions and the image isn't even properly centered due to the way I did it. I feel like this shouldn't be as hard as it is, but I just don't know how to do it properly and I can't find any reliable and working info. Essentially the problems I'm trying to solve are:

- Stencil that can be animated to move/scale/rotate around with everything outside it rendered black (right now the skull is actually surrounded by a huge area of black pixels in order to cover the screen, this makes it impossible to center or scale/rotate the skull properly and also makes it stretch with screen sizes)

- 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

TooMuchAbstraction posted:

:doh: that was it; hadn't put the shader into the right render queue, nor specified a blend mode. Thank you!
:pram: sometimes it's the simplest things

Your Computer
Oct 3, 2008




Grimey Drawer

KillHour posted:

Unity has an option to load the scene in the background without actually moving you over to it and it has a way of checking if it's done. You can start that process at the beginning of the fade out and don't do the fade in until you see that everything is loaded.

https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadSceneAsync.html
It works :toot: can't tell if I'm doing it right or it will cause problems down the road though. Like, do I have to worry about unloading the previous scene?

TooMuchAbstraction posted:

I wish I knew how to load a scene in Unity without immediately transitioning to it. As far as I can tell its asynchronous scene-load is meant to be used for things like animated loading screens, not for loading stuff in the background.

I guess what I'd do though is something like:
  • When the loading trigger is hit, render the current view to a texture.
  • (optional) Pop up a "loading" text in the corner.
  • When the next scene is loaded, it loads with that texture overlaid on top of it (use a RawImage with a material set to use the texture).
  • Skull-fade the texture away to see the new scene.

That won't stop the loading lag, but it should at least make things consistent.
I actually considered using a render texture for the skull effect since it's easy to use the UI with a stencil over another image (just not the screen itself) but that would make every transition a freeze-frame and I don't want that :negative:

I'm wondering if the proper solution would be to write another shader and do some UV trickery or something but honestly I wouldn't even know where to start. Maybe there's a way I could do a two-camera setup where everything outside of the skull doesn't get rendered? Again not sure where I'd start though :v:

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

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?

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

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:

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!

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:

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:

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

Your Computer
Oct 3, 2008




Grimey Drawer

FuzzySlippers posted:

Spawn points are actually a good thing for a mono. I'd have a mono SpawnPoint.cs you attach to a GO where you want to spawn. Typing vaguely from memory I'd do something like this

-snip-

You lazy load a singelton with whatever prefabs or unity data you need for a player. Create the SO ahead of time and place it in a Resources dir (the newer way to do this is with Addressables but that's more complicated). You have a non-Unity class to save whatever non-Unity data is important to your player that is easy to save to a file later.
thanks, that's super helpful! :kimchi: couple of things I'm wondering about -
your OnLevelExit where you set the PlayerData - could just as well put that on the player themselves yeah? That way I'm not passing around anything and the player takes care of its own stats. The player is already listening for an OnLevelExit event anyway (to lock inputs etc.) so it feels like a natural place to take care of that

conversely, the OnLevelLoaded I'm less sure about. I suppose it doesn't matter what it's on as long as it's part of every scene I want the player in, which makes it sound like a good fit for the level changer (I should probably rename that to level manager)? What it currently does is fade in the screen when the scene has loaded and listen for an OnLevelExit event to handle the scene loading and fade out. Seems reasonable that it takes care of spawning/placing the player too, no?


e: unrelated but another thing I've been wondering about - how do you handle a bunch of manually placed objects not cluttering up the hierarchy? I'm thinking of the logistics of placing like, 100 bones around a level and what a mess that would be :v: Since there's no grouping, maybe just parent everything to an empty gameobject and collapse it?

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

Your Computer
Oct 3, 2008




Grimey Drawer
sorry for doubleposting again but I'm very excited! I got everything working :woop:

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

no longer dragging and dropping the player prefab into each scene, instead each scene has (but doesn't require!) a LevelManager which handles the fading in, spawning the player, fading out and loading. I did the spawn points by making a little SpawnPoint script and attaching it to a GameObject that I can move around and tweak, and then the LevelManager keeps an array that I can drag my SpawnPoints into (and if there are none it just spawns the player at (0,0,0). Which spawn point to use is determined by an index contained in each loading zone's data and saved to the PlayerData when entering them so the LevelManager in the next scene knows where to spawn the player. Each loading zone and spawn point also has a Vector3 for exit/entry velocity so the player character can move automatically while the screen fades, and the player is given back controls once the fade-in is complete. Because the PlayerController handles these vectors, all the animations and stuff work as if the player was moving the character themselves and gravity is applied etc.

I could easily add more data to each loading zone (like being able to choose different transitions per loading zone or changing cameras or adding effects or w/e) or to the spawn points (same thing) without messing anything up or having to change any existing code, and since the LevelManager is per scene and not required I could make a CutsceneManager that does a similar job but without spawning the player character. Or a MinigameManager that sets up a minigame!

Your Computer fucked around with this message at 19:47 on Oct 23, 2019

Your Computer
Oct 3, 2008




Grimey Drawer

FuzzySlippers posted:

As far as scene hierarchy: there's overhead for every GameObject but not so much you should worry about a few extra here and there. I definitely keep all scene geometry behind a parent Level object for neatness sake.

However, every time a transform moves it sends messages up and down its hierarchy. If you have a bunch of moving transforms in a deep hierarchy with a ton of poo poo that's a lot of pointless messages. So at runtime anything moving gets moved to root. Like when I spawn an npc it goes to root.
that's good to know! Collectibles aren't going to be moving around anyway so it sounds like it'll be fine to just group them up and parent them to a GameObject then. I figure I gotta do something similar for billboards as well since they require having their own little script per billboard.

Also neat to hear how you've got things structured! It's something that has been surprisingly hard to find good info on (the #1 tip I've found by far is "put everything as DontDestroyOnLoad in a preload scene and make everything a singleton" which is like, the opposite of what I want) As far as UI goes I haven't really spent a lot of time thinking about it yet but my initial idea is to let the WhateverManager handle loading it from a prefab similarly to how I'm loading the player prefab. Since I'll want a different UI for different things (like menu, gameplay, minigame, cutscene etc.) I think it makes sense that their respective managers load them in.

Of course, I haven't actually done any UI work before in Unity so I'm not even sure if I can make them prefabs :v: The idea is that the UI will mostly be event driven anyway now that I've got the event system set up, so I'm hoping I can make it self-contained.

Shoehead posted:

Hi guys I added a very very important feature to my game yesterday.



No dialog!
...

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

Your Computer
Oct 3, 2008




Grimey Drawer

FuzzySlippers posted:

Keep in mind that Instantiate isn't cheap and isn't something that's great to be doing all the time if its avoidable. A UI prefab for something irregularly used makes total sense (a minigame) but I think constantly Instantiating a UI prefab for regular usage (menu, inventory) wouldn't be a great idea. Way better to just disable the object when not in use.

I also found that a complex UI got a little dodgy as a prefab and sometimes its serializing got glitchy or it occasionally tanked editor performance working on it. For that reason I have a special UI scene for all my regularly used UI bits and just additively load it into the first scene and I mark those UI roots as DontDestroyOnLoad. I can't imagine a time when I don't want those around in some capacity.
That's interesting. Couldn't the same be said for instantiating the player prefab?

As for complexity, considering the era I'm aping the UI is going to be very simple. I originally intended it to just be bitmaps but I figure that will be a huge pain if I want to change something or translate it so I guess I need to make some custom bitmap fonts. Like I said I've never actually done any UI in Unity before so this is all new to me, but since the UI elements will be different depending on what type of scene I figured that would be a logical way to split it up and make it easier to jump into any scene and have everything just work :shobon: I'm very keen on the idea being able to test a scene without having to preload anything or start from a specific setup scene, basically.

Speaking of UI I got DoozyUI in the humble bundle a bit back and I'm wondering I should try using that or if it would just be massive overkill and I'm better off using the built-in UI (since I'm just gonna make something very simple)

Your Computer
Oct 3, 2008




Grimey Drawer

Metos posted:

Instantiating the player once at the start of a scene isn't going to tank anything, FuzzySlippers is more referring to a 'When I press I it instantiates the inventory' or 'when I pick up a coin it instantiates a +1 coin icon' which are terrible because they could be happening 1000 times in a level as opposed to the once the player comes in.

Although don't leave UI disabled when not in use, leave them canvasGroup.alpha'd out so you don't get null references trying to update something that's turned off

Oh, well that makes sense. I figured the UI would just be another object in the scene so it gets instantiated once at the start of a scene just like the player. Am I thinking of UIs the wrong way entirely?

Your Computer
Oct 3, 2008




Grimey Drawer
I showed crouching earlier, now there's a backflip!




e: sidenote, has anyone gotten triggers to work reliably in Animator? I figured this might be a good use for them so I tried it, but it similarly to my previous experiences I found it really wonky. Even looking at the animator window, it seems like sometimes the trigger just... stays on? Which is not how triggers are supposed to work? For everything else I've just been using bools and manually setting them so I'll just do that for this too but still, it feels weird that I run into so much trouble with triggers.

Your Computer fucked around with this message at 16:18 on Oct 25, 2019

Your Computer
Oct 3, 2008




Grimey Drawer

KillHour posted:

The legs don't look like they're moving enough for the height and speed of the jump. Maybe have the legs overextend a bit before they leave the ground?
I know I still need to tweak the animation, this is just a first pass after all :shobon: I'm just excited about all the pieces fitting together and working, like going from idle to crouching and performing a jump out of a crouch doing a backflip instead of a regular jump. That sorta stuff.

I've already begun tweaking the animation, maybe this looks better?

Your Computer
Oct 3, 2008




Grimey Drawer

xzzy posted:

It looks pretty good I think, though if you really want more stuff to tweak I think the extra leg extension in the air could be removed. Like the legs should be at full extension as they leave the ground. When you jump you don't keep stretching out your legs as you float into the air.
I mean then we're basically back to the first animation


the player leaves the ground the moment the button is pressed, there is no amount of time spent on the ground during the backflip animation itself so there can't really be a "wind-up" period. I tried messing with adding a wind-up animation in my previous project and even just a couple of frames makes the controls feel unresponsive, it's one of those things you just gotta deal with when doing video game animation vs. conventional animation.

e: but like I said I'm just excited the code works :v: I can tweak the animations endlessly (the animation doesn't even have to be a backflip) and the exciting part for me is that it's working

Your Computer fucked around with this message at 17:35 on Oct 25, 2019

Your Computer
Oct 3, 2008




Grimey Drawer

KillHour posted:

What I mean is make the feet go down as fast as the player is going up. You'll have to make the legs longer than they should be do to this, but it will look fine because it's a cartoon.

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

See how the legs stretch to keep contact with the ground?
something similar was suggested with the doublejump (of "leaving behind" parts of the rig) but I simply can't figure out a way to actually feasibly do that. I could animate the legs to go downwards like you're suggesting but it would have to be at the exact same velocity as the player is moving up, and the only way that would look right is if it's synced up exactly with the jump code. Any changes to the code would require changes to the animation. This would also be even more of a nightmare since I'm not even manually setting the player's jump velocity, it's calculated backwards from the desired jump height and time. :v:

it's probably one of those things you could do easily with root motion, but that's a different workflow entirely and not what I'm after for this project. My animations and movement code are completely decoupled - the animations all happen at (0, 0, 0) and don't move around, and all player movement is handled by the code.

KillHour posted:

Also, congrats on getting it working. I know that's a big deal.
thanks :toot:

Adbot
ADBOT LOVES YOU

Your Computer
Oct 3, 2008




Grimey Drawer

ZombieApostate posted:

IK the feet to the ground instead of animating it :can:

that's another thing I can't actually do even if I wanted to because I'm using all generic rigs and Unity only supports IK for Humanoid Avatars :pseudo:

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