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"

Moving Actor back and forth using lerp(vector)?

Hello, I'm trying to make an actor move from left to right using lerp rather than timeline because I'm trying to create a simple enemy. So far I'm stuck at getting the actor to move back and forth below is my blueprint and thanks for the help!alt text

Product Version: UE 4.9
image1.png (118.2 kB)
more ▼

asked Jan 22 '16 at 02:02 PM in Blueprint Scripting

avatar image

161 25 25 31

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

1 answer: sort voted first

Hello Oldsiren,

When using a Lerp, the Alpha determines what the lerp outputs as well as the A and B. If the Alpha is 0, it'll output A and if it's 1, it'll output B. If it is set to any fraction between, it'll output that point between those two vectors. As an example, if you put 0.5 for the alpha, it'll do half way between the two points. If you need help with setting up the alpha value you need, please let me know.

Hope this helps!

more ▼

answered Jan 22 '16 at 02:42 PM

avatar image Oldsiren Jan 22 '16 at 03:01 PM

I do need help with setting up the alpha value, I'm attempting at have it interpolate back and forth from 1 to 0 but I have no idea how.

avatar image Matthew J Jan 22 '16 at 04:18 PM

I know you said that you didn't want to use timelines but using a timeline would be the easiest way to go about this. I'm sure there are other ways the reverse looping part, especially with Event Dispatchers but I'm going to keep it simple.

First, a screenshot of the nodes:

alt text

First part is simple, setting up the initial and destination values. I have mine just moving upwards 300 units. Inside of the timeline, I just have a Float curve with 2 keys. The first key is set to value 0, time 0. The second key is set to a value of 1 (the max for the alpha for the Lerp) and 3 time, to make it take 3 seconds to travel. Be sure to set the Length to 3 (or the time you choose). I then plugged the output into the lerp's alpha. After that I had to set up how it loops backwards. I figured it'd be easiest to use a boolean so I made a boolean that is true by default. When it finishes the timeline the first time, it'll check the boolean, find that it is true, set it to false, and then reverse the timeline from the end. The next time it'll to the opposite and this creates the looping movement.

The benefit to this is that you're setting this all up on beginplay instead of constantly calling it on Tick. This way it'll be more performant and also won't be framerate dependent.

avatar image FrederickD Mar 19 '16 at 04:31 PM

How would you go about this if you want to set the time it takes with a variable ? Can We create timelines at runtime or alter it's speed ?

How to setup an interpolation with getWorldDeltaSeconds ?

avatar image FrederickD Mar 19 '16 at 05:05 PM

nevermind, found the vInterpTo node...

avatar image Oldsiren Jan 22 '16 at 04:39 PM

Thank you this was extremely helpful!

(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