I have a series of statistics, such as “STAMINA”. Each is represented by a percentage where 90%+ is “Great”, 80%+ is “OK”, 70+ is “Tiring”… etc. The text description is what the player sees.
What’s the most efficient and clear way of converting the percentage to the text description? My previous experience is with VB; and we’d have used a SELECT CASE for this; but that’s babblespeak here, I know.
I’d rather not nest a long line of branches! (For example~:)
Thanks for replying so quickly. I’m not sure what the Left String function is doing here, so I’m unclear on how to check this is working. I’m also not sure what we’re looking up in the String array (my guess)…
Thanks. I was a bit put off by it as it’s tricky to comprehend, but your solution does work. Having done some additional searching, I don’t seem to the only one who has struggled when trying to “Switch” on “Integer Range”.
I think, however, I have found a more elegant solution by building a reusable function. (I need to do this on at least two other values)
no problem, i enjoy the challenge. i enhanced it and now it works from 0 to 100 with no issues. previous algo had an issue with percentages less than ex: 2% would be reported as 20% now its fixed. only 1 branch
I did have a little poke about with that; but the fact it would still need branch logic to work in my case makes it a bit of a faff. If there was a “Switch on Bool” of some sorts, maybe… but with 6 ranges to work with, InRange doesn’t seem to be my saviour.
Is there a way to implement it in a neat fashion, do you think? The method I’ve dreamed up above, with the Pure Function is useful (to me) as it’s reusable.
But it does not really give you lots of flexibility or granularity
does not really give you lots of flexibility or granularity
BUT! You could make the Map 100 elements long, each int is associated with a descriptor:
Then you can control which descriptors kicks precisely at which percent, with the precision of 1 percent. You could quickly make it in a spreadsheet, chuck it into the data table even. Sounds like an overkill but it would be neat-ish in a way.
You could also remap the range of stat values to an index using a curve.
So, you’d have a curve going from STAMINA to a 0 … 1 value, which would let you control the resolution and response, and then you’d have something that picks one of N strings from that 0 … 1 range.
i second curve use. I just discovered them not long ago and have found that they can save tons of nodes and make for easier iteration/experimentation. Anything from adjusting camera spring arm to animations to character rpg stat values. Pretty much anything. I wish I had learned about them sooner.
(just saying this to further motivate any future readers to take a moment to learn how to use curves )
This sounds quite inventive - and I’d like to try it. Familiar enough with the concept of mapping a curve to a timeframe or animation - but not to values like this. Do you have a recommendation for where to find a learning resource for this that might cover my needs? What I found in the documentation on curves seems to reflect things like animations.
These first two guys are both great for quick beginner intros. Always recommend them.
but it’s simple, just a couple screenshots from my own project probably gets idea across:
Here I am using a curve to change my characters speed based on the ground slope. Speed Curve (blue variable) is reference to the curve. Get Float Value takes a float input (in this case, the angle of ground), and the curve you create makes the corresponding outputs.
You can see up there at the top, I have said that when the input is 10, the output will be 1. In this case that means when the slope is slight, I multiply my speed by 1, so no change.
I am also using curves to change the spring arm length of the camera based on speed. helps give sense of momentum and acceleration.
I also use to update characters status effects like temperature, thirst, hunger, and so on. Basically, any time I want to map a range of values, I use a curve. Because the only other alternative I know if lengthy branch chains. With a curve it’s all in one easy to edit and visually understandable spot.
I think you might find more advanced examples related to animation in the Advanced Locomotion v4 project which is free.