How do I make so I can "push" the camera when I get the mouse close to the screen edge

Hello, I want to make the camera push around when the mouse moves close to the screen’s edge. Something like this

but without having to hold down click, if possible moving it smoothly. I have tried some youtube tutorials but I can’t get UE to manually detect the mouse and get the mouse delta to move the camera accordingly. Help would be appreciated

Hi there,

Think you can

Controller->GetHitResultsUnderCursorByChannel->BreakResults->ImpactLocation

TargetRotation = FindLookAtRotation (PlayerCameraPositon, ImpactLocation)

OnTick->SetCameraRotation – > RotationInterpTo (PlayerCameraRotation, TargetRotation, Speed, Tick )

If you use controller rotation SetController rotation that should work too but if you just want on the edges think you have to calculate mouse position in screen first. You can access that too and upon reaching edges( if X< Number || X>Number) same for y-axis too do tick operation for rotation.

Let me know if it helps

1 Like

Hi there, thank you for your reply, but, I cannot seem to locate the following nodes:

PlayerCameraPosition, SetCameraRotation, PlayerCameraRotation

I couldn’t also find some nodes by the name you gave me, but I saw similar names and figured they should work, correct me if I am mistaken.

ImpactLocation → Hit Result Location

Also, I don’t quite get the last part where you say:

Could you explain it again but in dumber terms? I am quite new to the engine and I’m still figuring it out.

By the way, it would help me a lot if you could provide some pictures of a blueprint that does what you described. Thanks again

Hey no worries,

Since you want to control camera, the settings of how its setup really effects our logic. Sometimes we use options in pawn/camera/springarm → Use Controller Yaw/Pitch/Roll with UseControllerDesiredRotation. for different view models.

Like in 3rd person camera should act differently depending on gameplay and gameplay ux. I press forward, then back → Should my character pawn turn to controller side or not?

In camera can be also options like

depending on how you setup our logic can be different. However this is for a third person template for 5.6.

This simply will follow my mouse rotation.

However we have to control camera to world interaction right? Like when this function should fire? If fired everytick it will always try turn on one side, is this something we want? etc. etc.

So I will just do things according to mouse pos, calculate a delta from center, check if its above some threshold and manipulate Controller Rot, which would work exactly like your video.

Results


If you don’t use controller rotation , you can simply delta rotate camera/spring arm relative to controller or something static in camera like below.

Since my character facing doesn’t change in capsule this time, I can just delta rotate spring arm. This is something more likelly you show since in the edges your camera stops as mouse delta, however both approaches are ok depending on what you do.

Results

Let us know.

Hi, is there anyway to make a “speed gradient” so that the further away from the center the mouse is, the faster the turning speed is?

By the way, this is exactly what I wanted to achieve this is just one extra detail that would just make it perfect.

In the first & seconds videos its already like that.
In the third video if you are referring to; you can do with multiple ways.

A correct way is to create a curve and get its values. Especially if you want complete control over your numbers and movements. Here is a nice tutorial in depth explaining base fundamentals of working with curves.

A simpler more direct way is keep factor rotation very small and get a double power exponent to values making it n to the power scaling to infinity.