Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Reverse a string with blueprints?


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!


Product Version: Not Selected
more ▼

asked Mar 26 '14 at 11:48 AM in Blueprint Scripting

avatar image

38 5 12 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

more ▼

answered Mar 26 '14 at 12:44 PM

avatar image

BrɑκеPɑd STAFF
1.4k 33 22 78

avatar image BrɑκеPɑd STAFF Mar 26 '14 at 12:58 PM

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

avatar image venain Mar 26 '14 at 06:00 PM

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.

avatar image venain Mar 26 '14 at 06:09 PM

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

alt text

reverse string.png (126.4 kB)
more ▼

answered Aug 08 '14 at 06:18 PM

avatar image

Jared Therriault
394 26 21 52

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question