How to implement Mouse Position Zoom on Character

Hi there, that is fairly simple.

You can start with getting the mouse position in the world with deproject.


LetsSayThis MouseDeprojectLoc

In you character / component / camera where ever you are writing logic;

MousePos = LineTraceSingle ( MouseDeprojectLoc, MouseDeprojectLoc + MouseDeprojectDir * 10000) ->Hit() -> HitLocation Example Tutorial

This is basically true world location under your mouse.

TargetCameraLoc = MousePos
CurrentCameraLoc = SpringArm->WorldLocation;

You can use this to OnMouseWheel-> Set (ZoomFractionLocation)

ZoomFractionLocation = Lerp (CurrentCameraLoc ,TargetCameraLoc , FractionOfZoom)

FractionOfZoom is something like 0.2 since you don’t want to go full zoom on one click or one wheel step. Simply by this you setting a location between your current camera and the mouse world since we want a gradual zoom.

Then you can simply zoom in

OnTick -> SetSpringArmLocation(VInterpTo (CurrentCameraLoc , ZoomFractionLocation, DeltaTime, Speed(5) ))

Recap:
OnMousewheel - > Set (ZoomFractionLocation )

OnTick → MovesCamera with Vinterp over time to ZoomFractionLocation