Reverse a string with blueprints?

Greetings,

I’m trying to figure out if there’s currently a way to reverse a string using the blueprint system, I don’t see anything obvious, but maybe someone has a method for this?

The reason I’d like to do this is to reverse floats (200 becomes .002, 50 becomes .05, etc) and use them as a vector lerp alpha for a system i’m building that involves picking up objects and having heavier objects take longer to move. In this case, the heavier object needs to be a smaller number, as smaller numbers will make the lerp slower, and larger ones will make the lerp faster.

In my head the only way I could think to do this would be to convert a float to a string, reverse it, and then convert it back to a float.

If anyone has any other suggestions on how to accomplish this, I’m all ears!

Thanks!

If you wanted a linear lerp between 0 and 1 for weights ranging between 0 and a max weight, try the following equation:

lerp = 1 - (1/(MaxWeight*ItemWeight);

This would give you a graph along the lines of:
http://fooplot.com/plot/64evwewhi2

I’ve taken 200 to be your max weight here…

In fact, 1-(Weight/MaxWeight) would do the same thing…

Hey thanks for this solution, it definitely works, but I’m not getting quite the result I want. The problem is that using this solution, the difference between 200kg and 50kg is almost not noticeable…

Let me explain what I’m doing a little better. My current method for moving the object around is to constantly lerp between where it was, to where the mouse is looking(i’m using the forward vector of the camera * the distance from the camera I want the object to be held + the cameras location)

The way I can control how much drag is happening is with the lerp alpha (0 = position a, 1 = position b)

The scale that seemed to work for me was that 200kg was a lerp alpha of .002, and 20kg was a lerp alpha of .02.

After thinking about it more, my original idea to reverse the number wont work either, because in that case, 50kg will be lighter than 20kg.

I’m stumped for the moment… There is a node that lets me move an object from one location to another over time, and this would be MUCH easier to scale via weight, but it has the side effect of making the object float in the air after I drop the object because it’s waiting for the move time to finish. Maybe i’ll have better luck fiddling with that node.

About 5 minutes after my comment I figured out how to stop the move to node when I press my interact key, this totally fixed the problem I had with it so I think I should be able to get it working the way I want.

Thanks for the help!

I know you got a workaround for your problem, but in case anyone is looking to reverse a string I have a solution.

Make a new function that has a string input and a string output. Make a local string variable as well.

The function takes in the string, converts it to a character array, then gets the last index of it. It then runs a For loop from zero until the last index and on each loop pass sets the local string variable to itself + a return string value. The return string value is returned like this: We take the current index on the for loop and subtract the last index of the character array (so if your index is 3, we return -1, essentially turning “Second-to-last” into “second”) then gets the absolute value of that returned integer. Then we get the character at the index we just calculated and append it to our string variable.

When the loop is completed, we return the string variable (after appends) to the return node.