# Get a Text Description based on an Integer or Float percentage

**URL:** <https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787>\
**Category:** Blueprint\
**Tags:** Blueprint-Utilities, unreal-engine, question, UE4-27\
**Created:** [March 17, 2022, 10:58pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787 "2022-03-17T22:58:16Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_bd5b06a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bd5b06a4](https://forums.unrealengine.com/u/anonymous_user_bd5b06a4)\
**Post date:** [March 17, 2022, 10:58pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/1 "2022-03-17T22:58:16Z")

</div>

What’s the best way to do this…?

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~:)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/7/6/676f42987d6ff0cfb8c13ae5bd37cae5da85eae9.png)

Surely this is a very inelegant way to do what I need here; given there’s two other stats I need to handle like this.

Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d774775f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d774775f1](https://forums.unrealengine.com/u/anonymous_user_d774775f1)\
**Post date:** [March 18, 2022, 1:55am UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/2 "2022-03-18T01:55:09Z")

</div>

i’d do it this way. its not perfect.

 ![Stamina](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/c/b/4cbd2a2a969a2ec31a03549781b2a76216aafc2a.jpeg)

come to think about it, no need for select.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bd5b06a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bd5b06a4](https://forums.unrealengine.com/u/anonymous_user_bd5b06a4)\
**Post date:** [March 18, 2022, 7:17am UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/3 "2022-03-18T07:17:50Z")

</div>

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)…

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/7/a07563ee12adaf732dd0479d0b678099e43c68b2.png)

So the question is how is it getting the correct descriptor for the percentage value of “Stamina”?

Cheers,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d774775f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d774775f1](https://forums.unrealengine.com/u/anonymous_user_d774775f1)\
**Post date:** [March 18, 2022, 9:09am UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/4 "2022-03-18T09:09:37Z")

</div>

i was in a hurry, i should not post while i am in a hurry.

here, i made it perfect but you will use 1 extra branch, im starting to question if its more efficient after these changes.

 ![Stamina-1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/9/169bbe097b62accb142a059557a6f92a34403d3f.jpeg)  
 ![Stamina-2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/f/4/df4dedca2aa6cb136dd2255c71c917cd347c78c4.jpeg)

forgot to tell you, this only works from 0 to 99 stamina if you want 100% you need to add an extra branch. up to you

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bd5b06a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bd5b06a4](https://forums.unrealengine.com/u/anonymous_user_bd5b06a4)\
**Post date:** [March 18, 2022, 12:36pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/5 "2022-03-18T12:36:56Z")

</div>

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)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/1/61165fe8dd657ff805baf419a6207dd2c04dec5b.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/9/6/696ba25b987844c48ca5c651df844ece78175f51.png)

It’s still using nested branches, which is annoying, (Oh for a SELECT CASE and BETWEEN) but it’s manageable as is.

Thank you so much for taking the trouble to reply and offer a solution.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d774775f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d774775f1](https://forums.unrealengine.com/u/anonymous_user_d774775f1)\
**Post date:** [March 18, 2022, 2:23pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/6 "2022-03-18T14:23:54Z")

</div>

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 🙂

 ![Stamina3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/2/3c25033cdb8b0167f33e895748f2fc3e77bcf6d4.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 18, 2022, 2:25pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/7 "2022-03-18T14:25:46Z")

</div>

@anonymous_user_d774775f1 Have a look at InRange nodes:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/3/ef3d351aae27bd22ace3022e1d9fe9418fe1622d.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bd5b06a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bd5b06a4](https://forums.unrealengine.com/u/anonymous_user_bd5b06a4)\
**Post date:** [March 18, 2022, 3:32pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/8 "2022-03-18T15:32:25Z")

</div>

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.

Thanks for your input.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 18, 2022, 3:54pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/9 "2022-03-18T15:54:44Z")

</div>

I was looking at this thread before, thinking this _pseudoscript_ would be neat:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/6/7/d679d25911268310ae0d16f524cb2fa86f1599c6.png)

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:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/d/1/8d18663505d0069e5c00916e5101af8ecb80333a.png)

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_.

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [March 18, 2022, 4:08pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/10 "2022-03-18T16:08:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 18, 2022, 4:14pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/11 "2022-03-18T16:14:45Z")

</div>

Ah, a curve would work! +1

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [March 18, 2022, 4:35pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/12 "2022-03-18T16:35:43Z")

</div>

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 )

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bd5b06a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bd5b06a4](https://forums.unrealengine.com/u/anonymous_user_bd5b06a4)\
**Post date:** [March 19, 2022, 4:39pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/13 "2022-03-19T16:39:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [March 19, 2022, 5:40pm UTC](https://forums.unrealengine.com/t/get-a-text-description-based-on-an-integer-or-float-percentage/507787/14 "2022-03-19T17:40:55Z")

</div>

[Unreal Engine - Slow/Speed Character Movement On Slopes (Simplest Method) - YouTube](https://www.youtube.com/watch?v=zJ6OPeo8Vmo)

here’s a lengthy step by step ^ . If you search unreal curves on youtube:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/9/449e14be4ec6f84962e4e009023a2e23314d598d.jpeg)  
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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/a/7ca08faf8980aa8358e6be0a0b7af1c80ddff023.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/5/f/85f0db50c5b3c167f293fe729a8647c11b1c44d9.png)

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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/d/a0d05f847ec9b4ffbe4fb29405a781279577f142.png)

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.
