Hey guys,
I hope you can help me out with an issue I have been spending way more time with than I expected: in my game I have a level that displays a world map with a top-down orthographic camera. The player should be able to zoom in and out the map by using the mouse wheel for instance. While the general zooming is no problem and I just add to/subtract from the camera’s OrthoWidth property what I actually want is that behavior that allows you to zoom into a certain point (where your cursor’s at). Just like the zoom in the blueprint editor works. So the zoom is centered at the cursor point, which stands still while everything else is (seemingly) shifted through the zoom. I understand that I need to apply an offset to the camera related to that cursor position and I have a solution that somewhat works and zooms in the correct direction but I have been spending two days trying to find the correct way to calculate the offset that I need to apply to the camera’s translation.
What I have
- Camera position in world space
- Camera properties: orthographic width in world units, aspect ratio
- The cursor position in screen and world space (where I want to zoom to)
- The zoom factor (float) that is applied during this Tick cycle
I’ve been trying all sorts and could need some fresh input. I appreciate any help/ideas and if you need any additional information, please let me know. Also, preferably I need to sovle this in blueprints.
Cheers!