# Problem with rotating smoothly towards direction

**URL:** <https://forums.unrealengine.com/t/problem-with-rotating-smoothly-towards-direction/467660>\
**Category:** Community & Industry Discussion\
**Tags:** rotation, lerp, unreal-engine, question\
**Created:** [July 4, 2020, 9:07pm UTC](https://forums.unrealengine.com/t/problem-with-rotating-smoothly-towards-direction/467660 "2020-07-04T21:07:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TeiserMan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TeiserMan](https://forums.unrealengine.com/u/TeiserMan)\
**Post date:** [July 4, 2020, 9:07pm UTC](https://forums.unrealengine.com/t/problem-with-rotating-smoothly-towards-direction/467660/1 "2020-07-04T21:07:43Z")

</div>

I have following line running in `Tick()`:

```
SetActorRotation(FMath::Lerp(GetActorRotation(), Direction.Rotation(), Speed));

```

Where `Direction` is a normalized `FVector` and `Speed` is a float between 0 and 1.

Im expecting this to interpolate the actors rotation towards `Direction`, but what happens is that the new direction is simply `Direction * Speed`, no matter how many frames passes.

Im sure that it is running in `Tick()`, `Direction` and `Speed` where constant when testing. I can’t figure out what’s wrong.

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 4, 2020, 10:50pm UTC](https://forums.unrealengine.com/t/problem-with-rotating-smoothly-towards-direction/467660/2 "2020-07-04T22:50:06Z")

</div>

If you want to interpolate between updated rotation and targeted rotation then use RInterpTo:

```
SetActorRotation(FMath::RInterpTo(GetActorRotation(), Direction.Rotation(), DeltaTime, Speed));

```

If you use Lerp, you just can’t use values that change as parameters. So you can’t use GetActorRotation() directly, but you must use it’s initial value. So save it in a variable (outside the Tick function), and then use that value as the first parameter.

Edit: Also, the third parameter in Lerp should be Alpha, which must go from 0 → 1 as time goes by. If your speed has a value greater than 1.0, then lerp will always return Direction.Rotation().

---

<div class="post-metadata">

**Author:** ![TeiserMan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TeiserMan](https://forums.unrealengine.com/u/TeiserMan)\
**Post date:** [July 5, 2020, 3:26pm UTC](https://forums.unrealengine.com/t/problem-with-rotating-smoothly-towards-direction/467660/3 "2020-07-05T15:26:59Z")

</div>

I figured out the problem wasn’t caused by the code, but by an overwrite of bUseControllerRotationYaw i had accidently made in the editor. Lerp and RInterpTo results in the same behaviour if speed in Lerp is multiplied by DeltaTime. Using RInterpTo might be preferable though, because it is cleaner and not a “hack”.
