Download

Increase a float value when approaching an object

Hello everyone,

I have a tree, and i want to increase a float value when i’m near this tree.

So if the difference between the player location and the tree are big, the float value are low.
If the difference between the player location and the tree are small, the float value are high.

Do you have any idea of how to do it ?

I was wondering if there is a way to assign a float value between two min & max values, depend on an entry value ?

For exemple :

IF distance between the player and the tree = 0 THEN the float value = 15 000 (15 000 = max value)
IF distance between the player and the tree = 300 THEN the float value = 0 (0 = min value)

Thanks a lot :slight_smile:

You’ll want to look into ‘normalize to range’ and ‘lerp (float)’

Like this:

Or like this, same as above but in a single node:

Annotation 2020-07-29 182708.jpg

There is also the *Unclamped *version of this node which will push the values beyond the provided A-B Range.

Thanks a lot guys, [USER=“13335”]Jared Therriault[/USER] & @Everynone for your help, it’s perfect !! :slight_smile:

Awesome, I’ve been using UE4 for almost 7 years and never knew about that :smiley: Thanks for the tip!