# SetRelativeRotation doesn't work in C++, but works in blueprint

**URL:** <https://forums.unrealengine.com/t/setrelativerotation-doesnt-work-in-c-but-works-in-blueprint/822291>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [March 25, 2023, 6:43pm UTC](https://forums.unrealengine.com/t/setrelativerotation-doesnt-work-in-c-but-works-in-blueprint/822291 "2023-03-25T18:43:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![runyonave](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@runyonave](https://forums.unrealengine.com/u/runyonave)\
**Post date:** [March 25, 2023, 6:43pm UTC](https://forums.unrealengine.com/t/setrelativerotation-doesnt-work-in-c-but-works-in-blueprint/822291/1 "2023-03-25T18:43:03Z")

</div>

I am not sure what is going on here, I have the following components in a Pawn blueprint:

![Screenshot 2023-03-25 143531](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/2/f22028558731e62e5f2d57d057a1c5a85efd3f2a.png)

I am trying to add a pitch to the `PlayerSceneComponent`. When I set the following in either in `BeginPlay` or `Tick`:

```auto
PlayerSceneComponent->SetRelativeRotation(FRotator(0.f, 45, 0.f));

```

The scene component rotates on the Yaw and NOT on Pitch.

If I set it in the blueprint:

![Screenshot 2023-03-25 144553](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/1/3e17e17cce4d0cbff26e89fcb00137ff8961ea0e.png)

Then the component rotates on the pitch.

Is there something that is different about how `SetRelativeRotation` is handled on the c++ side that I am missing?

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [March 25, 2023, 6:49pm UTC](https://forums.unrealengine.com/t/setrelativerotation-doesnt-work-in-c-but-works-in-blueprint/822291/2 "2023-03-25T18:49:31Z")

</div>

c++ in the documentation states that in the set relative rotation it takes in a FRotator that has a constructor

```auto
FRotator(float InPitch, float InYaw, float InRoll)

```

So if you want to rotate pitch then you need to set the first parameter to 45

if you are setting this in the tick function in c++ make sure that tick is enabled in the constructor  
for actor:

```auto
PrimaryActorTick.bCanEverTick = true;

```

for component

```auto
PrimaryComponentTick.bCanEverTick = true;

```

---

<div class="post-metadata">

**Author:** ![runyonave](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@runyonave](https://forums.unrealengine.com/u/runyonave)\
**Post date:** [March 26, 2023, 3:19am UTC](https://forums.unrealengine.com/t/setrelativerotation-doesnt-work-in-c-but-works-in-blueprint/822291/3 "2023-03-26T03:19:17Z")

</div>

Thank you so much! I should have referred to the manual regarding the `FRotator`. This solved the issue.
