2D mouse controlled sprite positioning

I have a 2D side-scroller project that I want to add projectile weapons too. My problem is figuring out how to set up in blueprint a way to have a sprite follow the mouse on a fixed axis in rotation depending on where the mouse is positioned.

For example, a sprite of an actor holding a separate sprite of a rifle where in which the rifle rotates depending on where the mouse is positioned, and can fire from said location. Without altering the actor’s sprites.

I’m fairly new to Unreal Engine/Blueprint and had trouble finding a solution to my problem.

Any help would be greatly appreciated, thank you for your time.

I’m very sorry, I only have worked in C++ but maybe this math will still help you…

    FVector mouseLoc = //the mouse location  (the followed object location)
    FVector gunLoc = //mygun->relativelocation;   (the following object location)
    FVector newrot = mouseLoc - gunLoc;
    
    
    	
    FRotator rot = FRotationMatrix::MakeFromX(newrot).Rotator();
    
    GunComponent->RelativeRotation.Pitch = rot.Pitch;