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
Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Ok I'll try to consider a higher construct I could build for this. I'm a bit unsure why you spent a lot of your post telling me about cost. My actions have costs. Distance is part of that cost calculation.

That's just not really what I'm having an issue with.

Adbot
ADBOT LOVES YOU

jizzy sillage
Aug 13, 2006

KillHour posted:

Just keep in mind that you will have to traverse the cost tree similar to pathfinding every time you need to make a decision, so it can become computationally expensive.

All the examples I could find used a progressive search through the tree for the planning algorithm, which is SO BAD. Nolgthorn, I think you mentioned you wrote one that starts at the end, which is good. If you start at the 50 possible actions you have, it's some bonkers huge number of dead end plans. If you start at the end, with the 3 of those 50 actions that actually lead to the goal state, you have a slightly less huge number of plans.

I'm sure someone who knows complexity notation could do the math but I was not paying attention in class that day.

KillHour
Oct 28, 2007


Nolgthorn posted:

Ok I'll try to consider a higher construct I could build for this. I'm a bit unsure why you spent a lot of your post telling me about cost. My actions have costs. Distance is part of that cost calculation.

That's just not really what I'm having an issue with.

You specifically said that your GOAP has no idea how far away your actor is from the crate and that the pathfinding information is calculated after you have a plan already.

Edit: reread more carefully. It sounds like your problem is just that the search space is huge. And... yeah, it's huge. You'll have to figure out clever ways to narrow it down.

I'm not sure I like the idea of figuring out the list of all possible actions before trying to figure out costs for those actions. You know you're only going to take one, so if you figure out the costs as you go and weight checking the branches appropriately, you can just do the first one that "finishes." Basically, breadth first instead of depth first. You can treat impossible steps as infinity cost for this.

jizzy sillage posted:

All the examples I could find used a progressive search through the tree for the planning algorithm, which is SO BAD. Nolgthorn, I think you mentioned you wrote one that starts at the end, which is good. If you start at the 50 possible actions you have, it's some bonkers huge number of dead end plans. If you start at the end, with the 3 of those 50 actions that actually lead to the goal state, you have a slightly less huge number of plans.

I'm sure someone who knows complexity notation could do the math but I was not paying attention in class that day.

The direction you traverse the tree probably doesn't matter in the long run. If the impossible step is the last one, going backwards is faster, but if the impossible step is the first one, forwards is faster. It likely averages out.

KillHour fucked around with this message at 06:39 on Aug 7, 2020

jizzy sillage
Aug 13, 2006

Plus you'll need something to pass out goals to the agents rather than them self-selecting, or you'll get 50 agents all running over to build the thing, or snatching the last of a resource before another guy who needs it arrives.

KillHour posted:

The direction you traverse the tree probably doesn't matter in the long run. If the impossible step is the last one, going backwards is faster, but if the impossible step is the first one, forwards is faster. It likely averages out.

Ah, mine is a turn based tactical game. There's always a valid option for each of my goals, it just sucks. If they can't shoot, they'll punch.

edit: ...does that mean it's still 50/50 on whether it's faster forwards or backwards? gently caress, lol

jizzy sillage fucked around with this message at 06:48 on Aug 7, 2020

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I start at the end, I go to the start, until I have a bunch of plans without pathfinding or distance calculations. At that point I can calculate pathfinding. The alternative is to calculate from start to goal and include pathfinding as I go along but that doesn't make sense. I'd be doing my most expensive calculations on plans that aren't possible, or don't reach the goal.

Anyway maybe goap just isn't what I need in the first place. What kind of ai would a base building game use. There's tons of actors just running around performing tasks you only generally set.

KillHour
Oct 28, 2007


Nolgthorn posted:

I start at the end, I go to the start, until I have a bunch of plans without pathfinding or distance calculations. At that point I can calculate pathfinding. The alternative is to calculate from start to goal and include pathfinding as I go along but that doesn't make sense. I'd be doing my most expensive calculations on plans that aren't possible, or don't reach the goal.

Anyway maybe goap just isn't what I need in the first place. What kind of ai would a base building game use. There's tons of actors just running around performing tasks you only generally set.

GOAP makes sense for that. I assumed you were talking about a computer AI that is against the player, not a bunch of small AIs with goals assigned by the player. I would probably traverse the tree with pathfinding as I go along, BUT I'd cache the pathfinding costs with a vector field.

https://gamedevelopment.tutsplus.com/tutorials/understanding-goal-based-vector-field-pathfinding--gamedev-9007

This will give you a cost from every location on the map to your final goal, which you can use to estimate the cost of several waypoints at once. You probably don't need the absolute shortest route, just a pretty good one.

Since it's 2AM, I'll leave the implantation details as an exercise to the reader.

KillHour fucked around with this message at 07:07 on Aug 7, 2020

BoneMonkey
Jul 25, 2008

I am happy for you.

Nolgthorn posted:

I start at the end, I go to the start, until I have a bunch of plans without pathfinding or distance calculations. At that point I can calculate pathfinding. The alternative is to calculate from start to goal and include pathfinding as I go along but that doesn't make sense. I'd be doing my most expensive calculations on plans that aren't possible, or don't reach the goal.

Anyway maybe goap just isn't what I need in the first place. What kind of ai would a base building game use. There's tons of actors just running around performing tasks you only generally set.

I'm having a lot of luck with utility AI.

It kinda works the other way. Each action is worked out and given a score. Between 0 and 1, top scorer is what happens that frame. It allows for a lot of fuzzy choices. Like reload is 0.23, but attack is 0.72. So the unit attacks. Now a if the enemy unit moves out of range or dies or something else the attack score drops and the unit will reload.

The great thing about this system, is that it's highly modular, I have a bunch of different abilities that my units can use, and each ability had its own consideration list. (Sometimes more that one, ie, should dash towards an enemy? Or should I dash out of danger?.)

The other thing is it can be pretty cheap as well. Like should I chase an enemy might need a ray trace or some path finding. But you can put a bunch of cheaper check earlier on in the consideration list, like am I reloading right now? What's my health like? And if any of those scores return zero, then you just don't do the checks after.

(Though I would warn that putting in all the optimization early. It can make it a little hard to work with. At the moment while I'm still tinkering with it I just have all my inputs fire, then do the considerations using those inputs, and then the action is just pull off the top of a list.)

Sorry this probably didn't make a huge amount of sense, I'm phone posting. But you can find out more about utility AI at this dudes website http://intrinsicalgorithm.com/works.php
He does a bunch of talks on it.

OtspIII
Sep 22, 2002

How deep do your action chains ever go and how many different types of action can your ais do in service of an action? My understanding is that goap is great for relatively complex branching action choices, but I'm not sure that what you need ever goes past "if holding relevant resource, go to target, otherwise go to closest relevant resource", which honestly might not need any sort of fancy ai framework. It all depends a bit on the details of the game, though

If the player says 'build a tower', but towers need wood, so the builder grabs an axe, chops down three trees, then drags the lumber to the build site--that's goap.

If the builder has to choose between twenty pieces of wood, considering factors like wood quality and how close the wood is to the nearest enemy and coming to a balanced choice, that's utility.

If the tower needs three wood, so three (and only three) builders leap into action and drag over one wood apiece, that's a task manager.

If the builder you manually assigned runs to the nearest wood and drags it to the tower, that's fine just being if statements.

This all goes out the window when you get to cpu player ai, of course.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I haven't begun tackling cpu players yet.

Not deep, like probably they're doing two or three things in sequence. Something more complicated they might do is "If you're carrying something and it isn't the right thing then drop it and go get the right thing." But that isn't goap. So I'm gonna strip this thing down, continue on with my refactor as I have been doing.

There's quite a lot to do with "Is this thing already targeted by someone else?" or "Is that space already occupied, or targeted to be occupied?" and things like that. The most complicated aspects of my ai all seem to be centred around avoiding two actors attempting to do the same thing.

I don't think I need goap at all.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Yeah I didn't need goap at all.

Now I've got plans which are collections of actions, actions have costs and therefore plans have costs. I need to define plans individually but that doesn't really matter, I think I'm ending up with way way less code overall and I have a lot more control without a lot of extra complexity.

It felt like I was trying to follow best practices and learn maybe about some standard methods of implementing ai, but my early impressions were ultimately correct. Which is that ai design is very fluid with not a lot of "the way to do it" that I've been able to find. I even bought a course or two about it, promising to teach me such things which really just bandied about. In the end you've got to design ai in your own way it seems. I had a similar experience learning state machines, turns out a state machine is a complicated way of saying 'enum'. Then there's a whole bunch of stuff you can tack on around it but the core of it is it's an enum.

Beyond understanding that, you just need to have a set of things for the actor to do and pick one, that's all ai is.

Nolgthorn fucked around with this message at 00:40 on Aug 14, 2020

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Nolgthorn posted:

I had a similar experience learning state machines, turns out a state machine is a complicated way of saying 'enum'. Then there's a whole bunch of stuff you can tack on around it but the core of it is it's an enum.
Ha, that's so true. I recently finally learned what dependency injection *really* is, which is "it's taking pre-constructed dependencies as constructor parameters rather than taking the values you need to construct the dependencies and constructing them yourself." It's not those loving frameworks that make code hard to navigate, it's not complicated, and it's not actually an improvement most of the time.

This is why I especially hate Java, because everything is referred to as "the [weird-magic-word] pattern" that could often be described in the same number of words in real human language.

Plinkey
Aug 4, 2004

by Fluffdaddy

roomforthetuna posted:

Ha, that's so true. I recently finally learned what dependency injection *really* is, which is "it's taking pre-constructed dependencies as constructor parameters rather than taking the values you need to construct the dependencies and constructing them yourself." It's not those loving frameworks that make code hard to navigate, it's not complicated, and it's not actually an improvement most of the time.

This is why I especially hate Java, because everything is referred to as "the [weird-magic-word] pattern" that could often be described in the same number of words in real human language.

DI is really, really good for unit testing though, if you're not developing in a corporate envirionment or doing it for your job there's rarely a really good reason to do it, coming from C# at least, it obfuscates the code if you don't know the pattern and can figure out what's going on pretty fast, but if one of your requirements is that your code needs to pass unit tests to be approved for a PR you learn it. This is also from a mostly web/API, not developing a game.

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
Building your classes so that they don't retrieve their own dependencies at runtime is simply good style, IMO. It means that as long as you have the parameters for the constructor, you can use that class in any context. Plus of course it makes refactoring super easy because the class is already portable and ready to be relocated.

And if you make a habit of it then it's just part of the style guide for your project.

Plinkey
Aug 4, 2004

by Fluffdaddy

TooMuchAbstraction posted:

Building your classes so that they don't retrieve their own dependencies at runtime is simply good style, IMO. It means that as long as you have the parameters for the constructor, you can use that class in any context. Plus of course it makes refactoring super easy because the class is already portable and ready to be relocated.

And if you make a habit of it then it's just part of the style guide for your project.

Yeah, I agree, but that's not always the reality.

Unless you are talking about your parameters being things like database providers, or API providers that you can mock to test.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Plinkey posted:

DI is really, really good for unit testing though, if you're not developing in a corporate envirionment or doing it for your job there's rarely a really good reason to do it, coming from C# at least, it obfuscates the code if you don't know the pattern and can figure out what's going on pretty fast, but if one of your requirements is that your code needs to pass unit tests to be approved for a PR you learn it. This is also from a mostly web/API, not developing a game.
That's context dependent too it turns out. DI in Dart/Flutter for example adds a pointless extra layer of complexity that doesn't do poo poo to aid unit testing.

But yeah, I wasn't fair to it really, I do actually like dependency injection in C++ where you do it by just passing in the things, and in other languages if you do it that way too, and only do it when it's actually appropriate and helpful. What I hate is the DI frameworks for other languages that make it so you "don't have to" include the dependencies directly, which it turns out is a synonym of "it completely obscures the links between classes so it's a massive pain to find what's using what if you don't already know". C++ style DI is good for unit tests, but Java-Guice style DI, for example, is not good for anything.

Plinkey
Aug 4, 2004

by Fluffdaddy

roomforthetuna posted:

That's context dependent too it turns out. DI in Dart/Flutter for example adds a pointless extra layer of complexity that doesn't do poo poo to aid unit testing.

But yeah, I wasn't fair to it really, I do actually like dependency injection in C++ where you do it by just passing in the things, and in other languages if you do it that way too, and only do it when it's actually appropriate and helpful. What I hate is the DI frameworks for other languages that make it so you "don't have to" include the dependencies directly, which it turns out is a synonym of "it completely obscures the links between classes so it's a massive pain to find what's using what if you don't already know". C++ style DI is good for unit tests, but Java-Guice style DI, for example, is not good for anything.

Yeah, gotcha, we have a pretty well defined DI pattern that's just used for testing and takes new devs a bit to get up to speed on, because most of them have never, ever seen DI.

You IClassThing with whatever is has to do, then implement ClassThing with the guts, and then we use I think Moq to override the IClassThing for testing. I'm not a fan, but whatever. It's not like we're switching implementations at runtime for a real DI.

Plinkey
Aug 4, 2004

by Fluffdaddy
This approach also has huge drawbacks that we're experiencing now, because the IClassThing that was made a year ago doesn't have a concept of something like duplicate, copy, move, delete...etc so you're writing dumb code while trying to figure out what it should do. Because testing was too expensive to do upfront for stuff that might not be used (it will be used)

e: also the guy that wrote it quit to go work for google or some poo poo

Raenir Salazar
Nov 5, 2010

"According to Wikipedia" there is a black hole that emits zionist hawking radiation where my brain should have been

I really should just shut the fuck up and stop posting forever
College Slice
So I have the following problem.

I have a world map I am trying to generate, divided into biomes.

Each biome has a starting height from 0 to 1 (% of the total height of the map).

Each biome has a blend percent from 0 to 1 (typically 0.2 to 0.3 has nice results).

I'd like for any given pixel at coordinates x/y to have a weight based on how much from 0 to 1 to determine which biome influences that pixel.

I am having difficulty thinking of the math needed to assign that weight.

(The biome's borders are also adjusted based on Noise but lets not worry about that)

Here's my current code:

code:
        float biomeWeight = 0;
        int numBiomes = settings.biomeColourSettings.biomes.Length;
        float blendRange = settings.biomeColourSettings.blendAmount / 2f + .001f;
        float[] biomesWeights = new float[numBiomes];
        float[] heights = new float[numBiomes];

        // pre-generate the points of interest
        for (int i = 0; i < numBiomes; i++)
        {
            float dst = heightPercent - settings.biomeColourSettings.biomes[i].startHeight;
            heights[i] = Mathf.InverseLerp(-blendRange, blendRange, dst); // 0 to 1, mult by 2 and subtract 1 to make it -1 to 1
        }

        // for each biome, calculate the biome weights
        for (int i = 0; i < numBiomes; i++)
        {
            for (int j = 0; j < numBiomes; j++)
            {
                // I figure something should be here  so that the weights set according to the influence
                // but I'm stuck on how exactly to do that
                biomesWeights[i] = biomeWeight;
            }
        }

        return biomesWeights;
Basically I'm just sort of stuck. For a given pixel, it is either complete in a biome (in which case its weight for that biome is 1, and 0 for all others). Or its in a blending area. Where it could be between 0 and 1 for any biome such that all these weights for that pixel adds up to 1.

Additionally, if there are multiple say more than 2 biomes, if a pixel is "above" the "start height" of multiple biomes I want to avoid the false positive of it being assigned to multiple biomes when it's in reality only in a single biome. (Because imagine Biome 0 starts at 0, Biomes 1 starts at 0.5, a pixel at 100% or up top might end up assigned to *both* biomes when it's clearly should only be in biome 1?)

Any suggestions?

Plinkey
Aug 4, 2004

by Fluffdaddy
Complete, off the wall suggestion, while I'm up late programming, but have you thought about using a gausain blur and randomly assigning bigger sqaures a 0-1 value and just let the algorithm take care of it?

OtspIII
Sep 22, 2002

I'm not 100% sure I'm following on the biome stuff. Is it that. . .

* You have a height-map already set up nicely

* Some height ranges only have one possible biome (deep ocean, tall mountains)

* Some height ranges can have multiple possible options (desert vs jungle vs grassland)

* You want the areas with multiple possible options to have contiguous zones of biomes rather than just being random pixels of a bunch of different biomes scattered together, and you're asking how to get those smooth borders?

When I've done a similar project I basically created a second heightmap using multiple layers of perlin noise at different scales (you could call it a rainfall map or something). Then I'd just say that if height was < 0.3 or so, that's ocean, over 0.7 or so and that's mountain. If it's between 0.3-0.7, then I use the rainfall map to determine biome-- < 0.3 is desert, 0.3-0.7 is grassland, > 0.7 is jungle. Basically, for each height/rainfall there's only ever a single biome that can exist, so you don't have to worry about "which of the valid ones do I pick"

Here's what it looked like in practice:

Raenir Salazar
Nov 5, 2010

"According to Wikipedia" there is a black hole that emits zionist hawking radiation where my brain should have been

I really should just shut the fuck up and stop posting forever
College Slice
My biomes are based on y-axis to reflect different climates while terrain is based on the height map.



Currently the biomes seem broken where one of the biomes is missing, and one of the biomes is doing both poles.

With this approach using random noise I can adjust the biomes semi randomly to make the biomes a little more natural looking and represent the fact that this should be a globe.

So basically the idea is to basically mix the approach you've described there different terrain at different heights have different colours; with biomes defined along latitudes that use different colour gradients to reflect dryer/wetter/colder/etc climates but along like, "bands" of the map instead of being more random pockets.

Raenir Salazar
Nov 5, 2010

"According to Wikipedia" there is a black hole that emits zionist hawking radiation where my brain should have been

I really should just shut the fuck up and stop posting forever
College Slice
A few extra details about whats going wrong from my perspective, right now with my old code, it generates this:



It should be a red-green gradient for the bottom band; but instead it's the top gradient, so my weights are wrong is my guess.

The function for that result looks this:

code:
    public float[] BiomePercentFromPoint(Vector2 pointOnPlane, int width, int height)
    {
        float heightPercent = pointOnPlane.y;

        if (settings.biomeColourSettings.noise.filterType == NoiseSettings.FilterType.PERLIN)
        {
            pointOnPlane.x *= width;
            pointOnPlane.y *= height;
        }

        float noiseHeightAtPoint = biomeNoiseFilter.Evaluate(pointOnPlane, width, height);
        heightPercent += (noiseHeightAtPoint - settings.biomeColourSettings.noiseOffset);

        // noise
        float biomeWeight = 0;
        int numBiomes = settings.biomeColourSettings.biomes.Length;
        float blendRange = settings.biomeColourSettings.blendAmount / 2f + .001f;
        float[] biomesWeights = new float[numBiomes];

        for (int i = 0; i < numBiomes; i++)
        {
            float dst = heightPercent - settings.biomeColourSettings.biomes[i].startHeight;
            float weight = Mathf.InverseLerp(-blendRange, blendRange, dst) * 2 - 1;
            biomeWeight *= (1 - weight);
            biomeWeight += (i * weight);
            biomesWeights[i] = Mathf.Abs(biomeWeight / Mathf.Max(1, biomeWeight / numBiomes - 1));

        }

        return biomesWeights;
    }

excellent bird guy
Jan 1, 2020

by Cyrano4747
Any Pico-8 users here? I'm willing and able if anyone wants to make something. I already have some code written in an isometric RPG style. I'm good enough with pixel art, and I consider myself pretty good with chiptunes and general musicianship. I just don't like doing all the work myself, it's more fun with others. So give me a 'whatsup' and I'm happy to help. I'm not a control freak, pretty much just for fun and whatever is cool with me.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I couldn't find something in Unity for an in-game treeview control? Is there one?

If not, are there typical GUI alternatives to Unity's stuff? I am not looking forward to implementing a treeview and whatever else later.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
A long as I didn't look this up wrong I think unity has such a thing built in. It's called exactly that, treeview.

https://docs.unity3d.com/Manual/TreeViewAPI.html

I guess maybe I'm confused and this isn't an in game control. Godot's editor is apparently built using the same tools it uses in game so it has one, therefore you can put it into your game.

https://docs.godotengine.org/en/stable/classes/class_tree.html

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Massive success regarding my previously mentioned ai troubles. I just have plans now, and actions. Plans just straight up generate a list of actions necessary in order to do something.

So I create a plan for each possible thing an actor can do and then pick the one with the lowest cost. It's so simple. And now because I did it that way instead of using all the fancy stuff I can have movement also be just an action.

I've removed tons of code and the whole thing runs faster and really feels a lot more solid. I'm glad I did that.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Nolgthorn posted:

A long as I didn't look this up wrong I think unity has such a thing built in. It's called exactly that, treeview.

https://docs.unity3d.com/Manual/TreeViewAPI.html

I guess maybe I'm confused and this isn't an in game control. Godot's editor is apparently built using the same tools it uses in game so it has one, therefore you can put it into your game.

https://docs.godotengine.org/en/stable/classes/class_tree.html


That's for the editor. I'm looking for similar for in-game. It's absolutely confusing because there are multiple, simultaneous GUI technologies kicking around in Unity natively right now without getting into 3rd-party ones. So don't feel bad about it.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
This might be hyperbole but:

Every Godot update: "We've made these parts of the engine better!"

Every Unity update: "Features! Look at the shiny new features!"

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
If I wanted to have a TMPro_Text text window's text fade as the text move upwards, what could I do? I'm still in cube-programmer-art-land so I don't have a good mind for visuals. I assume I overlay a grayscale texture over the text and use that to control the alpha for the text, but I'm not really sure about the finer bits. I also wonder if it's something I could do with a shader instead that I could more regularly parameterize than goofing around with creating the right seed image.

Edit: I basically want some text to fade is it moved up beyond the screen. I figured it would be easier to have the text fade row-by-row of pixels versus each line of text fading uniformly but who knows. I can take either.

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

Rocko Bonaparte posted:

If I wanted to have a TMPro_Text text window's text fade as the text move upwards, what could I do? I'm still in cube-programmer-art-land so I don't have a good mind for visuals. I assume I overlay a grayscale texture over the text and use that to control the alpha for the text, but I'm not really sure about the finer bits. I also wonder if it's something I could do with a shader instead that I could more regularly parameterize than goofing around with creating the right seed image.

Edit: I basically want some text to fade is it moved up beyond the screen. I figured it would be easier to have the text fade row-by-row of pixels versus each line of text fading uniformly but who knows. I can take either.

You can adjust the color and alpha of TextMeshPro characters one by one:

code:
var info = text.textInfo;
...
            int matIndex = info.characterInfo[i].materialReferenceIndex;
            var colors = info.meshInfo[matIndex].colors32;
            var vertIndex = info.characterInfo[i].vertexIndex;
            for (int v = 0; v < 4; ++v) {
                colors[vertIndex + v].a = alpha;
            }
You could also use a separate TMP_Text for each line of text, and then set the color of the text object as a whole.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

TooMuchAbstraction posted:

You can adjust the color and alpha of TextMeshPro characters one by one:

Well, that's more than I thought I could do. It sounds like a pain if I wanted to progressively fade the text as it scrolled up the screen.

I considered having a separate box per line I'm scrolling, but I have some sense that some of the entries I am scrolling will be inherently multiline and that'll probably botch something. So I decided to just have one box that can normally display two whole lines at a time, allow three "entries" to be stored in the box regardless of size, and just add on new entries as old entries scroll up past the top. I'm kind of surprised how much of a pain in the rear end it is!

Edit: If I have to just put this all in a parent scrolling component or whatever then having multiple text boxes is probably just going to be easier to manage anyways. You can clearly see that I'm still stirring this all around in my head.

Rocko Bonaparte fucked around with this message at 05:31 on Aug 20, 2020

Mr Shiny Pants
Nov 12, 2012

Rocko Bonaparte posted:

Well, that's more than I thought I could do. It sounds like a pain if I wanted to progressively fade the text as it scrolled up the screen.

I considered having a separate box per line I'm scrolling, but I have some sense that some of the entries I am scrolling will be inherently multiline and that'll probably botch something. So I decided to just have one box that can normally display two whole lines at a time, allow three "entries" to be stored in the box regardless of size, and just add on new entries as old entries scroll up past the top. I'm kind of surprised how much of a pain in the rear end it is!

Edit: If I have to just put this all in a parent scrolling component or whatever then having multiple text boxes is probably just going to be easier to manage anyways. You can clearly see that I'm still stirring this all around in my head.
NM.

Sedgr
Sep 16, 2007

Neat!

Can use DoTween to control alpha as well if you want something thats a more out of the box solution.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Sedgr posted:

Can use DoTween to control alpha as well if you want something thats a more out of the box solution.

Hmm that has the perk of letting me run a callback when each line has finished moving off-screen.

I will try some stuff for a bit. I haven't touched the UI and 2d logic in awhile and I am being pretty clumsy. I think a year ago that I wouldn't have any fuss with it at all.

I tried to use a ScrollRect manage the scrolling. I spent an hour fiddling with the transforms while my experience with them slowly seeped back into my head. Then I realized I wasn't going to have a scroll control so I didn't even need a ScrollRect in the first place. Somebody else please reassure me that I am not alone fighting that stuff.

TIP
Mar 21, 2006

Your move, creep.



Sedgr posted:

Can use DoTween to control alpha as well if you want something thats a more out of the box solution.

I second the recommendation for DoTween, it provides a lot of very useful tools for animating in code and I use it all over the place in my game. Makes it much easier to animate the properties of lots of things, and also allows you to set up multiple timelines filled with tons of individual animations.

It was especially nice for me because it's very similar to GSAP, which I used to handle all the animations for my JavaScript projects.

Rocko Bonaparte posted:

I tried to use a ScrollRect manage the scrolling. I spent an hour fiddling with the transforms while my experience with them slowly seeped back into my head. Then I realized I wasn't going to have a scroll control so I didn't even need a ScrollRect in the first place. Somebody else please reassure me that I am not alone fighting that stuff.

Dealing with UI stuff in Unity is the one part that always stresses me out because I know I'm going to end up spending an hour trying to figure out how to do some trivial thing.

TIP fucked around with this message at 20:53 on Aug 20, 2020

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I actually finally sat down to really try to work on this. There is a strange problem. When the top-most text box at any time reaches the boundaries of the root canvas, that text box just disappears. I first got hit with this without even scrolling. The first text box just wasn't showing until I had the vertical group's canvas shifted down one pixel. When the scene starts, that text will be there, but the tween will move it up and poof. It just immediately disappears instead of having the text waft up the top of the viewable screen like I intended. I'm guessing something in Unity is deciding the text's top-left bit is super-important or something and effectively culls it out of rendering when that bit is technically no longer viewable. I'm guessing I can hit something with a wrench to make that better right in the editor, but I have no idea what.

Some more details: There are three text boxes with the goal of only fitting two lines worth of notifications up top at a time. I had to yell at Unity's anchoring and RectTransform stuff to get this far but I did get here. I decided to skip on overtly creating a ScrollRect because I don't plan to expose a user control to do the scrolling. The parent-child ordering here goes:

1. Canvas that can show two lines of text up at the top of the screen.
2. Canvas w/ Vertical Layout Group
3. Three TM_Pro text boxes.

I intend to move the canvas with the vertical layout group component to create the scroll effect. When all the text for the topmost text box has gone off the top, I intend to move it to the third position fill it with whatever's next.

Edit: I got the scrolling to work, but it was actually a side effect of messing around with positioning.

The scroller got a content fitter to make sure it was sized to the number of text boxes I had; it's dynamic since these boxes might have multiple lines. I just settled on that instead of trying to split messages across lines manually. That sounds easy at first until you try to account for word wrap and you're suddenly doing TMPro's job.

The scroller needed a spacing of 1 or it wouldn't do any layout. I still don't understand this. Without this, all three text boxes were just flung on top of each other as originally created in the editor.

Each text box also needed a content size fitter set to vertical preferred size fit.

What does any of this have to do with text boxes getting culled when their topmost bit went off the canvas? I have no idea. It just doesn't happen any more.

Rocko Bonaparte fucked around with this message at 20:31 on Aug 23, 2020

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Completely different thing: Whenever I stop a scene and try to immediately start it afterwards, nothing loads up right and I just get a pile of null reference errors. It's as sample as fairly quickly clicking the play button while it's running, which will register as a stop, and start. If I stop and give it even a thin quantum of time in the regular editor view, then it'll start up correctly. If the problem happens, I can stop the scene, wait a bit, start the scene, and be fine.

I've kind of taken this as a given with Unity for, like, ever, but I would imagine plenty of people would have complained about it. I really can't find anything.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
September is upon us, and October is right around the corner, which means it's time to get hyped for Octojam 7:


It's the one and only annual CHIP-8-themed game jam! Scratch that low-level programming itch, and see how much gameplay you can cram into a few kilobytes:

http://octojam.com

This year I wrote a pair of example games that participants can use as a starting point if they wish:

Into The GarlicScape


Super NeatBoy


(ok, that's the end of my shameless plug.)

ddiddles
Oct 21, 2008

Roses are red, violets are blue, I'm a schizophrenic and so am I
I'm banging my head trying to deal with quaternions and rotations, maybe theres a simple way to do this, but my googling is failing me.

I have two objects, ParentA and ParentB, each of those objects has a child empty game object ChildA and ChildB respectively. I want to rotate ParentB so that ChildA and ChildB line up, but with an inverted Y axis so the Z axis on each child object faces the other.

This is how the objects get instantiated, ParentA is the large floor and ParentB is the thinner one, I'm able to get ChildA and ChildB to line up.


ParentAs orientation


ChildA's orientation


ParentBs orientation


ChildB's rotation


I need to rotate ParentB (the thin piece) using ChildB as the rotation point, and end up where ChildA and ChildB Z axis' are facing each other. Basically I'm trying to build a random generated world full of rooms and connecting hallways.

ddiddles fucked around with this message at 01:49 on Sep 6, 2020

Adbot
ADBOT LOVES YOU

duck monster
Dec 15, 2004

I've *really* been enjoying hacking around on Godot. Unity never clicked with me and Unreal doesn't work on my crusty old mac, though I find myself much more comfortable noodling about in Unreal C++ than I am in C#. The only really serious problem I've found so far is material importings a bit goofy though there are some projectes on to improve that (One of which is translating blender material nodes to godot shader nodes) and the navigation mesh implementation is trash. Cant be edited in the IDE, and the autogenerated one is next to useless [It creates a mesh for walking around on, uh, the roof of the map. Doesnt seem to like convex shapes. Apparently its being rewritten for Godot 4 but I dont know when thats out. But other than that, this things a blast. The 2D stuff is *super* cool though, and I'd argue possibly better than Unitys.The only thing its really lacking in that front is Unitys massive library of prefabs for kitbashing. But thats OK, I'd rather make my own assets anyway.

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