Making the Characters head follow the cursor in a Sidescroller

So, what I’m trying to do is get the head of the character in my sidescroller (3d) to pitch to follow the cursor around the screen, so the character is always looking at where the cursor is.

I’ve been running around in the animation blueprint for hours now, I think I should be trying to rotate the head bone, but I’m not sure.

Thanks for any help.

Hi TheMelonofTruth,

Here’s a starting point for this. First thing I think you would need is to transform the ScreenPosition of the mouse to a 2d World Position. This is done like this :

Once you have it, you can calculate the angle needed between that position and the head of the player.

Once you have the angle, you can set it in your blueprint and access it from your animation blueprint and modify the bone accordingly.

Make sure the rotation setting are set properly, if not, the changes just won’t appear on your model. To set those setting you have to have the “Transform (Modify) Bone” node selected.

Hope this helps

Cheers

Thanks for the help , I now have the mouse location, I’ve been trying to get the head location using Get Bone Location By Name, so I can use that and the mouse location to run Find Look At Rotation to give me a rotation to plug into my bone. No luck so far though, head still not moving.
You’ve gotten me half way there though, so thanks for that.

Nice to see you’ve made some progress. I’m not on a computer that has unreal right now but I’ll do another pass in an hour or two and post a more detailed blueprint.

Hey TheMelonofTruth,

Sorry about the delay, you probably have it figured out by now, but here’s my whole BP in case you need it. I made it from the third person BP.

Things I did not mention in the first post, make sure you set the bone in the “Transform Modify Bone” node.

I added a + node between the World Direction and the final rotation because the head would rotate but not toward the axis I wanted.

Enjoy

Event Graph in the Animation BP :

Anim Graph in the Anim BP

This is something I added in the player character BP so I could see my mouse in game and debug properly

33642-playercharacterbp.png

1 Like

I got it working, not exactly as I originally wanted it, but working well enough to tell the player which direction they will attack or block in.
5 days, 5 days of being jammed on this problem and it works.
Thanks a bundle for the help mate, if you want to see some blueprints I can post them later, right now I’m getting a beer.

Glad you got it working and I hope the beer(s) were good !

If the issue is fixed and I can’t be of any further assistance can you please accept the answer so people using the search option can better see that this question has actual answer in it

Cheers,