Change camera location with mouse cursor movements

Hello! So im making a game where the camera is completely straight top down and i added a little bit of camera lag so the camera follows the player smoothly and is not stiff on the player. But now i want to add camera movement to wherever you have the mouse cursor too, without loosing sight of the player. So basically the player is in the middle and when you go with the cursor in the top right of the screen for example, the camera slightly moves in the top right, all while still following the player. The camera follows both basically. I cannot find any tutorial or documentation about this so i would really appreciate the help if anyone knows. I use blueprints. Thank you!

1 Like

Set the springarm location to be Absolute:

And then update it in the player:

Since the springarm is now absolute, it no longer matters if you’re using the Set Relative Location or Set World Location node for the component. It’s always relative to World anyway.


It can be done with relative location only but then you’ll need to deal with inverting transforms at some point.

1 Like

Hello, thank you very much for the reply. I tried recreating your blueprint but i cannot seem to get the right nodes, something just seems off. When i try and convert the pins everything breaks and i cannot connect them anymore… Do you know whats wrong here?

The nodes look OK at a glance. Did you set the component to work in the world space?

the changes i made on the camera work perfectly when i play. The camera is on top and it has a bit of lag, only the mouse cursor doesnt do anything. Its like the things i created in the blueprint do nothing.

Could you confirm that you:

[…]set the component to work in the world space?

Were you to disconnect the above script from Tick completely, the camera should be still and not move at all, no matter what. Could you confirm that?

So this is when the event tick is connected:


(i have to send 2 replies)

and this is when its disconnected:

The camera did work before that. (just like in the first screenshot)

when i set the location and rotation of the springarm back, everything goes back to normal like in the first screenshot.

Ugh. In this case it might be the UE5’s conversion nodes that do something odd. I don’t have UE5 but I know a guy.

@ClockworkOcean @pezzott1 Could you double check that snippet in UE5 - to me it looks as if it should work but I can’t tell for sure.

@ProLaunchpadder You could always try to construct the whole thing with just floats by breaking the vectors. Or debug it to see which operation spits out zeros. Since the camera does not follow the cursor, something resets the output values to 0.

1 Like

Bit tricky. There is no top down template now… :-/

1 Like

I mean, this should work with any camera setup? 3rd person perhaps?

1 Like

They did what?! How dare they? Everyone and their mother is doing the Lyra thing now, Lyra this, Lyra that… ;p

Meh, can’t even get this far…

Are we supposed to right click pins to convert them? How do people BP these days?

You can’t choose vector 2D…

After some fiddling you can, but

image

followed closely by

image

Oh oh!..

image

( testing… )

@ProLaunchpadder


some fiddling

Waiting for new PC parts to arrive as we speak, was hoping to have a dedicated brand new rig that does one thing only - UE5. Having second thoughts now if I’m made to jump the most mundane hoops…


It’s going to turn out that Get Viewport Size returns 0 because of an unreported UE5 bug. Or OP’s viewport has no focus and does not report mouse position. I’d print all those values to see if there is actual data to work with.

This is what I ended up with

I don’t know what it’s supposed to do :smiley:

1 Like

It’s supposed to produce a mouse position based screen-percentage offset for the camera:


Maybe UE5 addressed the way relative / world set location nodes work when transforms is absolute:

1 Like

Nope. It’s like a weird, distant third person cam

3p