# camera zoom on cursor

**URL:** <https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864>\
**Category:** Cinematics & Media\
**Tags:** zoom, unreal-engine, UE4, question, Blueprint\
**Created:** [February 18, 2016, 11:39am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864 "2016-02-18T11:39:32Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [February 18, 2016, 11:39am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/1 "2016-02-18T11:39:32Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [February 22, 2016, 12:45pm UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/2 "2016-02-22T12:45:12Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Aros\_Prince](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aros\_Prince](https://forums.unrealengine.com/u/Aros_Prince)\
**Post date:** [August 7, 2019, 8:11am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/3 "2019-08-07T08:11:29Z")

</div>

Bump.

Were you able to solve it? Or anyone else?

---

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [August 26, 2019, 3:07pm UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/4 "2019-08-26T15:07:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 26, 2019, 6:40pm UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/5 "2019-08-26T18:40:28Z")

</div>

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

![285907-zoom.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/f/c/1fc53f7b6370c75d6e353136a69ec32f6cee8714.gif)

---

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [August 27, 2019, 7:41am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/6 "2019-08-27T07:41:52Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 27, 2019, 7:45am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/7 "2019-08-27T07:45:40Z")

</div>

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… 🙂

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

---

<div class="post-metadata">

**Author:** ![Aros\_Prince](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aros\_Prince](https://forums.unrealengine.com/u/Aros_Prince)\
**Post date:** [August 27, 2019, 7:57am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/8 "2019-08-27T07:57:29Z")

</div>

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](https://forums.unrealengine.com/development-discussion/content-creation/1650332-zooming-to-a-specific-point-on-an-object)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 27, 2019, 8:00am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/9 "2019-08-27T08:00:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Aros\_Prince](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aros\_Prince](https://forums.unrealengine.com/u/Aros_Prince)\
**Post date:** [August 27, 2019, 9:20am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/10 "2019-08-27T09:20:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [August 27, 2019, 11:13am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/11 "2019-08-27T11:13:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Aros\_Prince](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aros\_Prince](https://forums.unrealengine.com/u/Aros_Prince)\
**Post date:** [August 28, 2019, 11:32am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/12 "2019-08-28T11:32:04Z")

</div>

I described the solution in here:  
[https://forums.unrealengine.com/development-discussion/content-creation/1650332-zooming-to-a-specific-point-on-an-object](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).

---

<div class="post-metadata">

**Author:** ![Aros\_Prince](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aros\_Prince](https://forums.unrealengine.com/u/Aros_Prince)\
**Post date:** [August 28, 2019, 11:53am UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/13 "2019-08-28T11:53:05Z")

</div>

Done - see below.

---

<div class="post-metadata">

**Author:** ![Pataloon](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pataloon/32/698823_2.png) [@Pataloon](https://forums.unrealengine.com/u/Pataloon)\
**Post date:** [October 13, 2022, 12:40pm UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/14 "2022-10-13T12:40:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Aros\_Prince](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aros\_Prince](https://forums.unrealengine.com/u/Aros_Prince)\
**Post date:** [October 13, 2022, 1:38pm UTC](https://forums.unrealengine.com/t/camera-zoom-on-cursor/347864/15 "2022-10-13T13:38:46Z")

</div>

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