Top-Down Camera mouse control

Hi, I’m new to UE. I’m making a top-down game. I’m trying to implement a ‘zoom’ for the camera, similar to aiming in Foxhole.

For example, if the character is at point A, and the cursor is at point B, I want the camera to be at a point directly between the two when right clicking.

Here’s my most successful (least unsuccessful?) attempt so far:

As an explanation, this takes the X & Y of the spring arm (CameraStart) and adds the X & Y of the point where the mouse pointer intersects the ground.

This kind of works, but is janky at best. When the mouse is in certain positions the camera will just orbit the character, and if I put the mouse at the top right of the screen it ‘zooms’ right.

I feel like there’s a better way to do this, but haven’t been able to find any guides online that explain what I’m after (it might just be I don’t know what to search).

Has anyone done this in the past or is there a good resource for me to look at?

Thanks for any help at all.

(Point1+Point2)/2
:thinking:

1 Like

Yeah thanks that’s what I’m going for, but as it stands the camera doesnt go towards the cursor when drawn as a vector from the character.

As an example, if I right click at the top right for the screen the camera goes down and to the right, and if right click to the right of the character the camera orbits the character clockwise.

As it stands I’d expect the camera to move to where the cursor is, but it doesn’t do that.

I’m not particularly asking for anyone to solve it for me but if someone can point me towards a useful resource it’d be helpful.

Here is something similar to the video

For example I just took a cube in the level as a character and my Player Pawn is just a flying camera

You may be able to employ the “distance” node along with an equation to solve this one. Id think something like distance vector/2 but I’m at work right now so I can’t sit down and work it out entirely. Hope that will help