How to switch camera over shoulder but still the camera aim at center?

Hello everyone, first time posting.

So I have been blueprinting some time and I want to implement switch camera over shoulder. I managed to implement a simple over shoulder switch but I want the camera aim at the impact or location I am aiming at. Similar to Rogue Company camera switch.

I have put together a clip of my issue and with Rogue Company camera switch is my goal.

I already have a linetrace where the projectile travels from, to impact point. But dont know if my camera setup is the correct way. I mean , I read something about using Player Camera Manager, using a camera manager class, Im looking into that also.

Could not upload here the video even though i did compression. So there is a link instead.

Reference:

[CameraSwitchVideo] (CameraSwitchIssueCompressed.mp4 - Google Drive)

[Blueprint] (CameraSwitch posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4)

Thanks!!

Usually in most shooters before a bullet is fired you do A line trace from the center of the screen and then you spawn the bullet at the muzzle such that it hits the place the line trace hits. If you implement this and then just move the camera using the set location node it shld work just fine

Check this out at 10:05 minutes, there is a double line trace. Don’t know if it is what you need, but it can increase accuracy in some cases.

This is a projectile transform function. Works for all cams 3PP/FPP/ADS etc.

Btw. Please show us the blueprint for switching the camera. It may be that you have to adjust some vector positions.
I set this up once and had no issues with aiming precision. Either take a screenshot, or better yet, paste it in here: https://blueprintue.com

Hey, thanks for taking your time and help me :smiley: appreciate it!

So i put together a clip of my issue and with rogue company camera switch is my goal.

I already have a linetrace where the projectile travels from, to impact point. But dont know if my camera setup is the correct way. I mean , I read something about using Player Camera Manager, using a camera manager class, Im looking into that also.

Im putting my clip and blueprint of cameraswitch.

Could not upload here the video even though i did compression.

Reference:

[CameraSwitchVideo] (CameraSwitchIssueCompressed.mp4 - Google Drive)

[Blueprint] (CameraSwitch posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4)

Thanks again!!

Hey, would you mind post you switch camera blueprint? Maybe I have done it wrong.

Thanks :smiley:

I dont really understand what you mean with set location? Setting the camera location where line trace hits? My goal is to only switch at relative location but the rotation is changed to where I am aiming, regardless if I move my mouse input. I have put a video of reference.

A linetrace is not the issue. The issue is when i switch the camera angle for example left shoulder, the camera moves but the crosshair is also moving according to camera location, it always points forward and not the location where I stopped moving my mouse, I hope I could explain myself haha :smiley:

I posted a video of me explaining my issue and the goal i want.

This is overkill.
On the camera switch button, drag out a flip flop. From the flip flop, connect to one timeline play from start and play from end.
You can put the x,y and z values all on the timeline.
Use a vinterp, put in the interp speed and “get world delta seconds” into the green input on the vinterp.
I used this so that the camera switch shoulders left to right, but also a little bit movement for further away and then close again, and also a bit up and down.
That way, you only have to affect the spring arm and never the camera itself.

If you have two shoulder button, I used Q and E, you can make custom events into the time line, from start and from end and then call these custom events from the two buttons, like the little R/L buttons on a controller.

EDIT: The Vinterp is of course for the spring arm offset locations. For the starting shoulder, just type in the default values, and make sure the next shoulder has the new values, otherwise it will snap switch in a weird way on the first switch, or be reversed.

Thanks for helping, @SigmaGames

I did what you said I think, and i admit is less code but it’s the same result as I had. Or maybe I did wrong. The thing is I want the camera rotation to look at impact point of line trace, similar to the video I posted as reference.

[Camera Switch] (CameraSwitch posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4) - is this the blueprint you said?

Yes, like this. You might also be able to just use the lerp and then alpha back and forth.

If you put the shoulder switching on a timer by event and put that on a loop, you can then watch this in action in simulation mode and watch from above to see what the camera is doing. I think it’s possible.
If you put something like a super long arrow component from The Center of the camera, or a line trace by channel from the event tick, you should be able to see where The Center of the camera is facing.

For rotating the camera, if you need to, I’m not sure what you should do.

EDIT: Of course using your old camera rotation code might work. For anything that has to do with vector math and clever solutions, I would recommend this channel:

Thanks! @anon98807946

I will look into his channel, I do belive is more with mathematical operations for my goal :frowning: haha

Hopefully I come with a solution and will post it.

Video Reference:

To me it seems that you’re using a variable trace distance and base some other calculations off that result. Rather than drawing the cursor where the trace terminates, you deproject the hit location and place the crosshair there. That would explain that uncanny shift.

I might be completely wrong. Could you elaborate on that? Can we see your tracing method?

Hey, thanks for helping out! @Everynone

I don’t think is from my line trace. It’s a simple line trace where I set the impact point. The crazy rotations is from when the timeline node updates my camera set rotation. And when I move my mouse or move character, then it changes the rotation aswell.

I really wounder how Rogue Company and Vigor managed to do that.

[My LineTrace from Camera] (LineTrace posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4)

I might be missing something crucial or not accounting for everything; is this the behaviour you’re after:

What other features apart from these are needed here:

  • avoid using actor forward vector when character movement is involved - it will give you a headache as soon as you start moving around
  • also, somewhere above I saw a Timeline + Interp - avoid, this leads to double interpolation and inconsistencies (may not matter here, though)

This was very helpful! @Everynone

But not exactly correct behaviour im looking for, but close! Though the line trace stays at same spot even though camera is switching, the center of camera is not pointing at linetrace hitpoint. But I tried your code and found out that when my animation is moving, the line trace is also moving a bit (not staying exactly at the impactpoint)

If you look closely at my reference video of Rogue Company camera switch part at the beginning.
The camera is rotating a little bit. It is moving in straight line and rotate to direction of impact point at same time, like curving a bit.

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.

I tried your solution and it was close!

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.

Wow! This looks very good and could work better than mine! @Everynone

We got similar result but yours rotate more and out of crosshair when I tried. Very close.

I got the result I wanted when adding a second camera for consistent linetrace and then rotate the active camera to impact point. Oh and thanks to your previous blueprint idea when you used actor for starting linetrace, I used a second camera for static linetrace and worked well.


Result: I can move mouse and character no problem.

Issue: Now it’s not linetracing from the new camera angle and always rotate to impact point because I have not cleared the timer. Also camera stutters because it is rotating to the impact point when behind objects.

My solution thoughts right now:

  • Can be fixed by clearing the timer to stop rotating.
  • Start new or change line trace from to my new camera angle.
  • Then see if working viceversa.