Do you know how convert mouse location to world space works? I have the same input system as you do, and basically decided that it didn’t do what I wanted and ended up just utilizing vector math to get the mouse location on the XY plane.
I can post the blueprint when I get home.
EDIT:
Alright. This is the blueprint.
Not sure if there’s a better way to do it, but it works for me. You can just copy it if you want but I’ll try explain for anyone that doesn’t understand.
The “set rotation” section is pretty straightforward. Just get the pawn location, the mouse target, and update the yaw of the pawn to face the target.
To actually get the mouse target, a little math needs to be done.
What I wanted for my game was for the mouse to be projected from the camera onto a horizontal plane the same level as the floor.
That way, if the player has the mouse on top of a tall object, the player will be facing the point on the floor behind the tall object rather than snap to face the bottom of the object. (I thought this was annoying in the top-down starter project)
We want to find the point of intersection between our floor plane and the line that goes from the camera position, through the mouse location in world space.
The plane for me is where Z = 0. You’ll probably have to do some more work that I haven’t done here if you have a slanted floor but hopefully your game isn’t as crazy as that.
We can make our line from two points; the location of the camera P1 and the location of the mouse in world space P2
We want x and y values for our mouse target, and we have a z value
We can use the parametric x,y,z equations for a line to get those.
x=P1x+dx*t
y=P1y+dy*t
z=P1z+dz*t
where dx,dy,dz is the difference vector from P1 to P2 and t is how far along the line from P1 to P2 the point is that the x,y,z values make.
We can easily work out the value of t where the line intersects our plane by setting z = 0.
Rearrange the z equation: t = (z - P1z) / dz.
z = 0 on our plane so t = - P1z / dz.
The difference vector is just P1 - P2, which there is a blueprint node for.
Then we can plug in t to the first two equations to find x and y, and that’s our mouse point.
You can replace 0 with another value, or use your player’s Z position instead so that it works on different elevations
Let me know if this helps you, or if there’s a better way to do it. I want to add the best method to the wiki.