# How to keep Third Person Camera on Target while lerping to new Socket Offset?

**URL:** <https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [June 22, 2023, 10:03pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784 "2023-06-22T22:03:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 22, 2023, 10:03pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/1 "2023-06-22T22:03:22Z")

</div>

Hello,  
I have a Third Person Character BP, with an Over-the-Shoulder setup; I’d like to give the player the ability to switch shoulders. I have a timeline with a lerp to change the socket offset of the camera boom, which works great when my character is not aiming his weapon.  
The problem: I wish for the camera to remain centered on the same location when switching shoulders, so players can stay on target; effectively only the camera changes location from the player’s POV. I’ve tried using findLookatRotation, but changing only the camera’s rotation screws with the orbit, and I’ve not found a reliable way to orientate the camera boom along with it.  
 ![UEFImg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/a/72a705cfc9f4cc2b9b809e59b6e2c0bcd4f0fee9.png)  
[Diagram of the Camera’s Original and Final Position.]  
Additionally, here’s some video reference of what I’m trying to reproduce.

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/b/77b68f60ce559ba7ad2151b027daa944d0f5ca18.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/b/77b68f60ce559ba7ad2151b027daa944d0f5ca18.mp4)
  
My solutions are either unprecise and orienting the camera at a relatively close position, don’t work for a gradual shift/rotation, or locks the camera rotation for the duration of the shift/rotation.

Any help, suggestion, specialized node(s), etc. is appreciated.

---

<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 23, 2023, 7:33am UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/2 "2023-06-23T07:33:23Z")

</div>

You could have two cameras? One always on each shoulder. Just blend between them when the player wants to switch.

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 23, 2023, 12:37pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/4 "2023-06-23T12:37:42Z")

</div>

(Deleted post is identical, simply not a reply)  
I think 2 cameras is a good idea, so I’ve set up an additional follow camera, with its own camera boom and socket offset (0, 100, 0 and 0, -150, 0 respectively).  
I’m not sure how to use the “set view target with blend” node with these character cameras, as I can’t connect them as the target nodes. The online documentation I found only show blending to static cameras.

---

<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 23, 2023, 12:40pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/5 "2023-06-23T12:40:58Z")

</div>

I saw this

> [@How to set view blend between two cameras within the character blueprint?](https://forums.unrealengine.com/t/how-to-set-view-blend-between-two-cameras-within-the-character-blueprint/432437):
>
> Hey guys I’ve been having lots of trouble trying to figure out a way to blend a first-person to third-person transition within blueprint. After player input, the blueprint runs through a flip-flop and then uses the Set View Target with Blend function. Flip-flop B (the return to first-person view) works perfectly fine and sets the new target to self. However flip-flop A sets the new target to a child actor that contains a camera (this is where the problem is). At the moment when I press “V” to c…

Basically, the second cam needs to be in an actor, and you make that a child.

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 23, 2023, 1:26pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/7 "2023-06-23T13:26:07Z")

</div>

I’ve figured out how to make it into an actor and child of the CharBP.  
I have a couple issues and also questions:  
Issue 1: I can’t rotate the camera and the camera rotates with the CharBP.  
Issue 2: I can’t seem to place my springarm inside the CharBP capsule, I think it collides with it otherwise and turns into a poor man’s 1st person.  
Question: Should I set up my first camera as a child actor too? What about additional cameras?

---

<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 23, 2023, 1:43pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/8 "2023-06-23T13:43:57Z")

</div>

I’m afraid I don’t know. Yes, you might have collision problems.

Another possibility, is just attaching two cams to the same swing arm, an setting the active camera.

These are just ideas. I haven’t actually tried any of them… ☺

Or: changing the camera position relative to the SA, that sounds promising…

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 23, 2023, 1:51pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/9 "2023-06-23T13:51:09Z")

</div>

It’s alright, even if it doesn’t solve my issue I’ve learnt more about cameras, so this is bound to be useful later on.

Yes, I think I should find a way to move both the Camera and the Swing Arm. I’ve tried making functions which set the control rotation to face a location relative to the Socket Offset, but that solution is actually the same exact problem with one extra unnecessary step.  
Thank you for your help. ^^

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 23, 2023, 2:01pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/11 "2023-06-23T14:01:28Z")

</div>

I make everything harder for myself, because rather than having the left offset be the mirrored right offset, it’s different, but that’s by design; long story short I’m making 4 offset depending on shoulder and the dominant hand:  
RR: 100  
LL: -100  
RL: -150  
LR: 150

Another problem I find with simply mirroring the rotation, is that it tends to not be the exact same spot; if I can have the camera keep the _exact_ same location I’d prefer that, so I do think “look at rotation” will be part of the equation because it’s to my knowledge the most appropriate for that.

(They should add a feature/function for cameras Swing Arms to adjust automatically to the camera’s desired rotation)

---

<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 23, 2023, 2:35pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/12 "2023-06-23T14:35:45Z")

</div>

Sorry, I’m bailing. Too fiddly.

I should have a 200ft high sign next to my desk: “Don’t answer questions about character rotation”.

☺

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 23, 2023, 2:51pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/13 "2023-06-23T14:51:51Z")

</div>

Hey, no problems; I don’t see a “results required” sign anywhere ^^  
Beside, as I’ve said, I learnt stuff about cameras, so that’s always a plus.  
Thank you for your help and time! 😃

---

<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 23, 2023, 2:52pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/14 "2023-06-23T14:52:34Z")

</div>

Thank you for being understanding 😃

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 23, 2023, 2:59pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/15 "2023-06-23T14:59:03Z")

</div>

@J-07211 See if this helps:

> [@How to switch camera over shoulder but still the camera aim at center?](https://forums.unrealengine.com/t/how-to-switch-camera-over-shoulder-but-still-the-camera-aim-at-center/499110/19):
>
> What I think is calculating the hitpoint of linetrace and tries to rotate camera to the direction of impact point and that is where im stuck. Sounds a bit like this: It’s this but it may as well open another can of worms. Even though UE4 caters to 1st/3rd person well enough, oftentimes I feel like spawning the pertinent components outside of the actor, skip attaching and do everything manually in the camera manager.

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 23, 2023, 4:45pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/16 "2023-06-23T16:45:58Z")

</div>

I stumbled upon that thread a couple weeks ago, and assuming I’m using it correctly, it didn’t as it screws with the Camera’s orbit around the Spring Arm.  
Here’s the test function I used:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/7/537b782ab33725420c30d5f05af5e5f6007fe077.png)  
TestCamera is a secondary camera, with its own ArmSpring and socket offset.  
The trace is made from the camera manager (+ (Forward Vector x 50000))  
The result: (Trace from both cameras, execute function, Trace again, then switch cameras)  

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/f/8ffdfd3cce837623b51a859fe289968ec3ecacfd.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/f/8ffdfd3cce837623b51a859fe289968ec3ecacfd.mp4)

I think the issue is modifying the rotation of the camera without adjusting the rotation of the swing arm with it.  
The inverse transform rotation node might be part of the final equation, on the other hand.

---

<div class="post-metadata">

**Author:** ![usa423](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/usa423/32/918773_2.png) [@usa423](https://forums.unrealengine.com/u/usa423)\
**Post date:** [June 24, 2023, 2:16am UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/18 "2023-06-24T02:16:55Z")

</div>

Like on the 2017 Battlefront 2. I would just use two cameras and switch them with some logic on a key press.

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 24, 2023, 7:17pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/19 "2023-06-24T19:17:49Z")

</div>

I’ve experimented some more with the 2 cameras idea, but I’ve hit a wall trying to orientate the second camera and its spring arm. If I can reliably rotate them both to face the direction I wish, then I could then add onto it a camera switch/lerp.

Something else I’ll use as a stop gap measure is a fonction which I find too complex for my taste, which is to calculate 2 square triangles:

Triangle 1:  
Side a: (c² - b²)  
Side b: Socket offset (100 in this case)  
Side c: Swing Arm to Target Location  
Triangle 2:  
Same calculations, but offset is (abs) -150 (so 150)  
Knowing those values, I can substract both Beta Angles (angle opposite side of b side) from 180 to know the rotation to add to the control rotation.  
This works well when the switch is instant, but the pitch needs some adjustement.  
Unfortunately when I tried it it didn’t do well with timelines, but I’ll try again, maybe it can be fixed.  
 ![UEFImgmod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/2/e/02e1a1fdfe81447fff57f276ff768ab20bcfe7af.png)

It’s a bit funny having to use trigonometry to just keep a camera looking at a point when using spring arms. Should I e-mail the Epic Dev Team to ask them?

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 24, 2023, 10:06pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/20 "2023-06-24T22:06:00Z")

</div>

Something that could be useful which I’ve found out:  
These 2 angles are identical, and it seems to be reproduced on other distances from camera to hit location.  
If it is in fact consistent, it could be used to quickly find the correct angle for the other camera/control rotation.

 ![Sans titre](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/e/65e3231a5bbe19903f6375ef64cafd6d92de4d11.png)  
Red square is current camera location  
Black & white is player location  
Blue is hit location of the camera + forward trace  
Middle Green is final location of the Camera with final spring arm rotation.

---

<div class="post-metadata">

**Author:** ![zeaf](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zeaf/32/1108035_2.png) [@zeaf](https://forums.unrealengine.com/u/zeaf)\
**Post date:** [June 25, 2023, 12:33am UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/21 "2023-06-25T00:33:52Z")

</div>

I managed to do it with a timeline and the two traces usually done for crosshairs (one from camera to camera forward, one from weapon to end of the first trace).

Then it’s just a matter of moving the camera using the timeline, and at the same time setting the control rotation to be the rotation from the camera to the result of the trace.  
During the transition you shouldn’t perform the trace, or if you do for other purposes, make sure you save the last target before the transition started, and use that to calculate the rotation.

I think the hard part is not making it work, but actually making sure that the design is correct, because the camera could potentially rotate a lot based on how far the thing you’re pointing at is from you. So you will have to think about potentially having a minimum range to allow this camera rotation, otherwise you will have some very jarring transitions

Here’s the test project I made for this:

> **[ShoulderSwap.rar](https://onedrive.live.com/redir?resid=D24D59228EFF47B9%21670408&authkey=%21ABc15VHONbe6yvE&e=joiRKJ)**
>
> Compressed (zipped) Folder

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 25, 2023, 12:47am UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/22 "2023-06-25T00:47:56Z")

</div>

Woah, I didn’t expect this much; I’ll test your project out tomorrow morning to make sure. Thank you.  
I’ll definitely have a minimum and maximum distance, during my testing a few weeks back I had problems with close ranges not working properly, plus it’s really jarring for how much the view rotates at close range when I had it working.

I’ll keep updates on progress.

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 25, 2023, 12:01pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/23 "2023-06-25T12:01:31Z")

</div>

I’ve tested your project with different arm length for the swing arm, as well as different socket offsets and it works like a charm so far.  
I’m gonna try and modify the set control rotation to add to the control rotation, rather than just set it; I had the exact same issue in an earlier test and it results in the player being unable to rotate their view while switching shoulder.

In short: Thank you. It works well, I’ll try and perfect it.

---

<div class="post-metadata">

**Author:** ![J-07211](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/j-07211/32/720100_2.png) [@J-07211](https://forums.unrealengine.com/u/J-07211)\
**Post date:** [June 27, 2023, 1:18pm UTC](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784/24 "2023-06-27T13:18:29Z")

</div>

The two main problems I’m trying to fix with the current blueprint are:

- Unable to move the camera while the switch is in progress. (Reason: Sets the control rotation to face the Target, which overrides the player’s input on the control rotation.)
- Inconsistent Target

By simply going back and forth after the timeline has finished, I’ve noticed that the camera was not looking at the exact same point everytime, which should not happen. Additionally, it seems that at the end of the timeline, the camera moves away from the target point, which adds the significant distance away from where it’s looking.

Any idea what causes this?  
I’m experimenting with a component, to have an semi-independent reference point for the camera to look at, which I haven’t been able to work, despite setting location and rotation as absolute.

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/3/d13ee809850bbc2f4d6b6a62cc0fd4a602dd393c.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/3/d13ee809850bbc2f4d6b6a62cc0fd4a602dd393c.mp4)
  
Here’s a video showing the strange discrepancy. The result is the same wheter I ask the control rotation to be the camera’s lookat to the target or this component I mentioned.  
I suspect is has something to do with the socket offset or the timeline, since setting the camera rotation rather than the control rotation yields the same result.

I’ll keep looking, any suggestion, idea, fix, etc. is appreciated.

[Next page](https://forums.unrealengine.com/t/how-to-keep-third-person-camera-on-target-while-lerping-to-new-socket-offset/1207784.md?page=2)
