Sidescroller with asset aiming towards mouse position

Hello! I’m trying to build a sidescroller that moves a character to the right of the screen and left, but most importantly an arrow that aim towards the mouse cursor’s position on the screen. The best example I can think of is Metal Slug’s tank:

I’ve made a couple of attempts to best replicate this effects but to no avail.
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_170614_1565466089923_103”,“title”:“convertmouselocation.PNG”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64

[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_170616_1565466161672_805”,“title”:“rotation_attempt.PNG”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64

The first one doesn’t rotate around the characters at all while the second only works in a limited range

Any help would be greatly appreciated! I’ll continue to find to find a solution!

Hi, are you having trouble finding the exact cursor location on the character’s movement plane, or with rotating the arrow towards it?

Rotating the arrow towards it. I found a solution, but it is a bit limited. When the arrow is close to 90 degrees aiming above the character its snaps about 5 degrees to the opposite side. I’m at work atm, but I can follow up later with a screenshot of my blueprints, the video I followed, and the results.

This BP I’m using is working great, but there is a noticeable snapping with aiming directly above. I’m hoping to have version that rotates as seamless as possible.

This was the video I followed: UE4 Questions Answered: SideScrolling aiming from start to finish - YouTube

use vectors.

(world_mouse_position - world_gun_pivot_position).normalize() - this will be direction of gun orientation in world space.
where world_gun_pivot_position is point where gun attached. in world space. it should be like local_gun_pivot_position + world_vehicle_position.

then convert direction to rotation using one of MakeRotFrom* functions, depending on your coordinate system.
and set gun rotation in world space.

to use local position, relative to vehicle position, simply subtract vehicle position from it:
local_mouse_position = world_mouse_position - world_vehicle_position;