camera zoom on cursor

Hi,
I’m looking for a blueprint setup for my zoom in/out camera.
How to make the camera target the cursor while zooming ?
I’ve tried with Get Mouse Position, but it’s only 2D coords. I’ve tried a ConvertMouseLocationToWorldSpace too, but my camera looks an object with a certain angle from the ground (20°), so there is a mismatch in one axis : each time I zoom, the camera moves on its Y axis (it probably don’t takes count of the difference between the Y coord of the camera and the distance between the camera and the targeted object).
I’m actually working with a camera attached to a spring arm (which length is modified to ajust the zoom), in a pawn class blueprint.

Any suggests would help, thanks !

Pop.

I’ve tried different ways, the best consists in converting the X/Y move of the cursor in the screen into %, and using this rate to scale the world location vector of the camera. But I’ve jumps from one position to another, as lerp doesn’t work correctly ; without explanation, even if the “set world location” node is linked to On Tick event, it only works during the time the wheel scroll “button” is activated (that is to say a fraction of second).

Has someone a working workflow ?

Bump.

Were you able to solve it? Or anyone else?

Well I didn’t il '16, and didn’t try since. No update since 4.10 about this ?

Do you mean like this? ( before I go into detail… )

285907-zoom.gif

As you can see in the GIF, when I move the cursor over the cube, the camera zooms. I’m just checking that’s what you were looking for, before posting huge amounts of code. But it sounds like you want top down… :slight_smile:

( I’m not moving closer to the cube, just mousing over )

Your gif is not very clear, but it seems to work. In my original post, I was working on a top-down view, the cursor was not the center of the screen, and it didn’t turn the camera around. Hard to me to explain a 3-years-old abandonned project though…
@Aros_Prince, any precise request ?

Well, I don’t quite get what you do with the cursor on the GIF but in the end I solved it like this:

https://forums.unrealengine.com/development-discussion/content-creation/1650332-zooming-to-a-specific-point-on-an-object

I’m just moving the cursor over the cube, and it zooms. I did it by changing the FOV, rather than moving the camera…

OK, but the cursor is always the center of the screen, right? In such a case it is really easy. But in my case, moving the cursor around does not affect the camera in any way. Messing around with the mouse wheel does. And I need to keep the cursor where it is. As stated above, the solution described under the link is fine in my case. But thanks anyway.

Nice solution you found there. Could you post it as an answer so that I can set it to solved ? Thanks a lot !

I described the solution in here:
https://forums.unrealengine.com/development-discussion/content-creation/1650332-zooming-to-a-specific-point-on-an-object

The trick is to get the point under the cursor by calling GetHitResultUnderCursorForObjects which will get you the impact point. You can than subtract the the camera’s world location from the impact point which will get you a direction in which you need to shift the camera (without rotating it). You can do that for example by multiplying the vector by say 0.1 and adding it to the camera world location. If you have the camera attached to a spring arm, you can simply update the target offset property.

Credits go to @foodi.

In case you need to also rotate the camera around a specific point, you need to employ some mechanism to reset the camera orientation. I use a timeline to interpolate the camera parameters when I need to reset it or start rotating the camera (see the link).

Done - see below.

If I may, I would translate into Blueprint? I’m struggling to understand. :confused:

What exactly don’t you understand? Our current solution is written in C++, not BP.