# Move actor relative to camera rotation?

**URL:** <https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329>\
**Category:** Cinematics & Media\
**Tags:** move-actor, unreal-engine, question\
**Created:** [June 24, 2021, 11:55pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329 "2021-06-24T23:55:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [June 24, 2021, 11:55pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/1 "2021-06-24T23:55:11Z")

</div>

I have an actor which gets attached to a scene component on the first person player character.

The attached actor can be moved around using the WASD keys (separate from the first person character, pic at bottom). I would like for this attached actor to always move in relation to the camera, i.e. if it is rotated 90 degrees or 180 degrees no matter, W key will always make it move away from the camera, and A will always move to left side of camera.

Is there a way to accomplish this without a big chain of vector math? Just want to make sure there isn’t a simpler way before I twist my brain in a knot.

Example:  
The compass and map are attached and follow the first person character around the world, taking on the characters rotation. If I add local offset to the compass, W will always move it along it’s local X axis. If I add world offset, it will not be aligned with the camera.

 ![342352-screenshot-2021-06-24-195909.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/e/eee0f0c666e7381e047e2f3ac9307aac7eba9455.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 25, 2021, 7:30am UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/2 "2021-06-25T07:30:34Z")

</div>

It’s not too bad I don’t think. For sure moving backwards and forwards in front of the camera will be accomplished by just taking the forward vector from the camera, so depending on W and S, it will always be some multiple of

 ![342355-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/1/4/81493b5bbb518d604db5414dae890e0daccfa5e3.jpeg)

For the rotation, I assume you want to rotate the object around it’s own pivot point?

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [June 25, 2021, 11:06am UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/3 "2021-06-25T11:06:49Z")

</div>

I’ll give this a shot today.

Rotation is already taken care of, it only rotates clockwise or counterclockwise on the Z axis so that never changes.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 25, 2021, 11:12am UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/4 "2021-06-25T11:12:14Z")

</div>

If it’s not that, then probably

 ![342364-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/9/4d95f1ac71e9454b2028a7a82506fe1455606081.jpeg)

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [June 25, 2021, 12:13pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/5 "2021-06-25T12:13:46Z")

</div>

Trying both of these approaches, for some reason it is snapping the actor above the camera.

I tried isolating only the X and Y parts of the vector but made no difference.

Maybe something to do with that I am attaching these actors to scene components on begin play. Maybe that attachment is getting overridden or something?

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [June 25, 2021, 12:15pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/6 "2021-06-25T12:15:42Z")

</div>

alt text

 ![342359-screenshot-2021-06-25-081409.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/3/40332c8977636b78eed5b22746d6a5612ba8ee72.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 25, 2021, 12:20pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/7 "2021-06-25T12:20:24Z")

</div>

Take the compass. Is it a standalone BP?

Do you mean you’re attaching it to a scene component inside the player?

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [June 25, 2021, 12:20pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/8 "2021-06-25T12:20:45Z")

</div>

Sorry, trouble getting these screenshots to work right.  
Screenshot above shows result after using this code:

 ![342360-screenshot-2021-06-25-081840.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/9/9/b99f913173eb8c9c9a56192e079b8387b814a9e8.jpeg)

I also tried with the cameras world position, and both using the AddOffset and SetLocation nodes. They all give the same result.

The actors 0,0,0 location is right beneath the camera. There should be no movement on the Z axis, only sliding along the X and Y plane.

I tried isolating the vector multiplications to only be on X and Y but it is still always moving up on the Z axis.

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [June 25, 2021, 12:26pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/9 "2021-06-25T12:26:21Z")

</div>

Yes that’s correct.

And disregard my last response, I did correct issue with movement along the Z axis.

Now I have expected movement, it’s just going wrong way. But that’s simple to solve. I will confirm then mark your answer correct once I make sure everything is in order. It looks like the only change to your code that was needed was to split the struct and only use the X and Y locations (in my case only).

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 25, 2021, 1:05pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/10 "2021-06-25T13:05:20Z")

</div>

It’s working then. Cool 🙂

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [June 26, 2021, 11:58am UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/11 "2021-06-26T11:58:45Z")

</div>

I’m happy to report there actually was an easy way to do this without vector math involved (or at least, Epic has already done the math for us.)

The AddRelativeLocation node does the trick, the key is it has to be used on the static mesh component, not the entire actor. To be honest I am not 100% sure what the difference is since the StaticMesh here is the root component of the actor, but in any case, it works.

Thanks for the help, it wasn’t in vain as I did learn a bit more about vector maths which will come in handy in the future I’m sure.

![342464-screenshot-2021-06-26-075652.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/3/ed39ec277b53c3e8a4a16413c9ec36f8ce3822dd.jpeg)

---

<div class="post-metadata">

**Author:** ![OrfWare](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/orfware/32/482755_2.png) [@OrfWare](https://forums.unrealengine.com/u/OrfWare)\
**Post date:** [October 1, 2022, 4:02pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/12 "2022-10-01T16:02:39Z")

</div>

Hi @BIGTIMEMASTER . I’d like to leasn to shape my links like yours - I’d love them to be made of true arcs + straight lines…

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [October 1, 2022, 4:12pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/13 "2022-10-01T16:12:04Z")

</div>

thats the electronic nodes plugin

---

<div class="post-metadata">

**Author:** ![OrfWare](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/orfware/32/482755_2.png) [@OrfWare](https://forums.unrealengine.com/u/OrfWare)\
**Post date:** [October 1, 2022, 4:44pm UTC](https://forums.unrealengine.com/t/move-actor-relative-to-camera-rotation/485329/14 "2022-10-01T16:44:58Z")

</div>

Thanks, I’m going to buy it right now!!! 😃
