# Moving Actor back and forth using lerp(vector)?

**URL:** <https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942>\
**Category:** Blueprint\
**Tags:** lerp, setactorlocation, unreal-engine, vector, UE4, question, Blueprint\
**Created:** [January 22, 2016, 2:02pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942 "2016-01-22T14:02:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![YawLighthouse](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yawlighthouse/32/1125831_2.png) [@YawLighthouse](https://forums.unrealengine.com/u/YawLighthouse)\
**Post date:** [January 22, 2016, 2:02pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/1 "2016-01-22T14:02:51Z")

</div>

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!

 ![75531-image1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/6/bf612261bd787c6b89650312f387a5f4a44c5d2a.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [January 22, 2016, 2:42pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/2 "2016-01-22T14:42:24Z")

</div>

Hello ,

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!

---

<div class="post-metadata">

**Author:** ![YawLighthouse](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yawlighthouse/32/1125831_2.png) [@YawLighthouse](https://forums.unrealengine.com/u/YawLighthouse)\
**Post date:** [January 22, 2016, 3:01pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/3 "2016-01-22T15:01:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [January 22, 2016, 4:18pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/4 "2016-01-22T16:18:04Z")

</div>

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:

 ![75540-blueprintscreenshot.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/6/c06b3161624082dc8f40613b291ea8b0f48a4764.png)

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.

---

<div class="post-metadata">

**Author:** ![YawLighthouse](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yawlighthouse/32/1125831_2.png) [@YawLighthouse](https://forums.unrealengine.com/u/YawLighthouse)\
**Post date:** [January 22, 2016, 4:39pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/5 "2016-01-22T16:39:39Z")

</div>

Thank you this was extremely helpful!

---

<div class="post-metadata">

**Author:** ![FrederickD](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FrederickD](https://forums.unrealengine.com/u/FrederickD)\
**Post date:** [March 19, 2016, 4:31pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/6 "2016-03-19T16:31:53Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![FrederickD](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FrederickD](https://forums.unrealengine.com/u/FrederickD)\
**Post date:** [March 19, 2016, 5:05pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/7 "2016-03-19T17:05:49Z")

</div>

nevermind, found the vInterpTo node…

---

<div class="post-metadata">

**Author:** ![Valsogard.com](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Valsogard.com](https://forums.unrealengine.com/u/Valsogard.com)\
**Post date:** [September 6, 2019, 2:14pm UTC](https://forums.unrealengine.com/t/moving-actor-back-and-forth-using-lerp-vector/344942/8 "2019-09-06T14:14:17Z")

</div>

@Matthev J You should use Flip Flop instead of these get and set boolean nodes.
