# How can I rotate an object so it always rotates towards a first person camera?

**URL:** <https://forums.unrealengine.com/t/how-can-i-rotate-an-object-so-it-always-rotates-towards-a-first-person-camera/452062>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 11, 2019, 9:55am UTC](https://forums.unrealengine.com/t/how-can-i-rotate-an-object-so-it-always-rotates-towards-a-first-person-camera/452062 "2019-07-11T09:55:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blargenswarg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Blargenswarg](https://forums.unrealengine.com/u/Blargenswarg)\
**Post date:** [July 11, 2019, 9:55am UTC](https://forums.unrealengine.com/t/how-can-i-rotate-an-object-so-it-always-rotates-towards-a-first-person-camera/452062/1 "2019-07-11T09:55:04Z")

</div>

I’m working on a project where the player can lift an object in front of them, once they hold an item they can rotate it with the mouse input while holding a button.

I’ve manage to make it so that moving the mouse from side to side rotates the object on the Z axis, but I want to make it so that moving the mouse up and down always _tilts_ the object towards and away from the camera regardless of which way the camera is pointing.

If I rotate it on the X or Y axis in local space it just tilts it depending on where the front of the object is pointing. Rotating it in world space tilts it the same direction regardless of everything else.

I think I either need to use the Rotator from Axis and Angle node, or figure out how to calculate the right amount of X and Y rotation to use in world space. But I can’t wrap my head around it.

---

<div class="post-metadata">

**Author:** ![Wattar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wattar](https://forums.unrealengine.com/u/Wattar)\
**Post date:** [July 11, 2019, 11:18am UTC](https://forums.unrealengine.com/t/how-can-i-rotate-an-object-so-it-always-rotates-towards-a-first-person-camera/452062/2 "2019-07-11T11:18:20Z")

</div>

I think an easy solution would be to add any component (maybe an Arrow component) or a socket that would act as an “Inspect Item Handle” as a child of your first person camera component and move it to the location you want the held object to be away from the camera.

Then when you want to inspect an object, attach it to that component and any rotation applied to the object will be always relative to the camera and that would do what you want.

Then take control of your Turn or Lookup input events if an object is held (simple boolean check or check if the component has any children) and apply relative rotation based on the mouse axis value. Here, i set up something quick for ya, hope it helps.

 ![282160-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/5/d/b5d7ee74b15f48e9ee93b410db532a96acc8182f.png)

---

<div class="post-metadata">

**Author:** ![Blargenswarg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Blargenswarg](https://forums.unrealengine.com/u/Blargenswarg)\
**Post date:** [July 11, 2019, 1:28pm UTC](https://forums.unrealengine.com/t/how-can-i-rotate-an-object-so-it-always-rotates-towards-a-first-person-camera/452062/3 "2019-07-11T13:28:00Z")

</div>

Thank you very much for your answer, but I don’t think I can solve it that easily without starting over. I’ve already set up a system that smoothly moves the object to the right place without attaching to components. I tried combining your solution with my system, but I don’t think I can do it without losing my smooth movement, and some other little things.

What I’ve been trying to do is set up a way to dynamically calculate a relative rotation that is angled in the right direction, but that seems to be more difficult than I first thought.

---

<div class="post-metadata">

**Author:** ![Wattar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wattar](https://forums.unrealengine.com/u/Wattar)\
**Post date:** [July 11, 2019, 6:40pm UTC](https://forums.unrealengine.com/t/how-can-i-rotate-an-object-so-it-always-rotates-towards-a-first-person-camera/452062/4 "2019-07-11T18:40:35Z")

</div>

Oh i understand, can you try this instead then? it should work 😃

 ![282169-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/f/b2fbf76e89871bf284d4f47a6bf81d90918d4c23.png)

and use camera’s forward vector for the left and right rotation.

---

<div class="post-metadata">

**Author:** ![Blargenswarg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Blargenswarg](https://forums.unrealengine.com/u/Blargenswarg)\
**Post date:** [July 12, 2019, 8:40am UTC](https://forums.unrealengine.com/t/how-can-i-rotate-an-object-so-it-always-rotates-towards-a-first-person-camera/452062/5 "2019-07-12T08:40:24Z")

</div>

Thank you, I managed to fix it using this 🙂
