# How to use Lerp Rotator in C++?

**URL:** <https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921>\
**Category:** C++\
**Tags:** UE4-20, unreal-engine, UE4, question, CPP\
**Created:** [May 3, 2022, 6:17pm UTC](https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921 "2022-05-03T18:17:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [May 3, 2022, 6:17pm UTC](https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921/1 "2022-05-03T18:17:06Z")

</div>

I would like to learn how to implement Lerp Rotator using C++? and how to set the Shortest Path to true in it.  
Thank You.

blueprint:

 ![image_2022-05-03_231649987](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/0/470be0495514279c1c612abccf707ddec724b113.png)

---

<div class="post-metadata">

**Author:** ![ilbeyataberkcan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ilbeyataberkcan](https://forums.unrealengine.com/u/ilbeyataberkcan)\
**Post date:** [May 3, 2022, 6:43pm UTC](https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921/2 "2022-05-03T18:43:42Z")

</div>

It’s explained quite simply and clearly on this post:

> [@Need Help With FMath::Lerp, FRotator And SetRelativeRotation](https://forums.unrealengine.com/t/need-help-with-fmath-lerp-frotator-and-setrelativerotation/143432/2):
>
> FMath::Lerp blends between two values based on an Alpha. The values you are blending between cannot change as you lerp (well, they can, but it doesn’t give the right effect). Because of the way rotations are handled (they wrap and are normalised) the standard ‘Lerp’ function doesn’t apply to them in the same way. For Rotators, you would usually convert them to Quaternions and use FQuat::Slerp(), or you can use FMath::RInterpTo to move towards a target rotation at a given speed. E.g.: FRotat…

Hope this can help 🙂

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [May 3, 2022, 6:49pm UTC](https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921/3 "2022-05-03T18:49:28Z")

</div>

FRotator NewRotation = FQuat::Slerp(Rotation1.ToQuat(), Rotation2.ToQuat(), Alpha);

for me this is not working, it says no suitable user found for conversion from rotator to fquat

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [May 3, 2022, 6:51pm UTC](https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921/4 "2022-05-03T18:51:06Z")

</div>

`FRotator NewRotation = FQuat::Slerp(AltReleasedRotation.ToQuat(), AltPressedRotation.ToQuat(), Percentage, true);`

this is what I am trying to do. I also need to set the **Shortest Path** to true

---

<div class="post-metadata">

**Author:** ![k\_a\_s\_s\_k\_a\_s\_s](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/k_a_s_s_k_a_s_s/32/555828_2.png) [@k\_a\_s\_s\_k\_a\_s\_s](https://forums.unrealengine.com/u/k_a_s_s_k_a_s_s)\
**Post date:** [May 4, 2022, 6:48am UTC](https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921/5 "2022-05-04T06:48:56Z")

</div>

`FQuat::SLerp` function is shortest path, so you’re on the right track. Non-shortest path is `FQuat::SlerpFullPath`.

The `no suitable user found for conversion from frotator to fquat` problem comes from the fact that you’re assigning to a `FRotator` variable a `FQuat` value (which comes from `FQuat::Slerp`).

You should construct a rotator from the quat like this `FRotator NewRotation = FRotator(FQuat::Slerp(Rotation1.ToQuat(), Rotation2.ToQuat(), Alpha));`

---

<div class="post-metadata">

**Author:** ![Alex\_Green](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alex_green/32/739078_2.png) [@Alex\_Green](https://forums.unrealengine.com/u/Alex_Green)\
**Post date:** [October 18, 2024, 4:26pm UTC](https://forums.unrealengine.com/t/how-to-use-lerp-rotator-in-c/547921/7 "2024-10-18T16:26:41Z")

</div>

Just look/use UKismetMathLibrary::RLerp() if you need exactly same logic as in BP.
