How to rotate the pitch of a character with the mouse position?

Hello guys,

I’m making a 2D SideScroller game with C++ and I want to rotate the head of the player with the mouse position, but it is not working. I tried FindLookAtRotation, but this doesn’t work.


I found a blueprint about rotation, but I don’t get it:

Hey there, the code image is invalid. Posting an in game picture would also help.


Your logic seems sound to me, one thing I noticed however is you are using the Screen Coordinates to calculate your angle, which will cause incorrect calculations since the players head location is in world coordinates. You will need to convert LocationX and LocationY to world position or convert players head location into screen position.

These functions might help you with this: ConvertScreenLocationToWorldSpace or ConvertWorldLocationToScreenLocation

Let me know if this solved your issue. If not I can take a more in-depth look when I get home and have access to the engine.

Thanks man! I didn’t know there was a ‘ConvertScreenLocationToWorldSpace’ function

No problem! I hope it works!

Happy coding!

Woot! Woot!

Haha, btw happy coding!

I already tried it, and it works.