Mouse Rotation

Hi there! I was wondering how should I procede in a game where I want to continuously rotate the pitch and yaw based on my mouse location. So basically i want to have a non conflict zone where if the cursor is in middle where nothing should happen.

but when I change it’s position, I want it to be able to rotate without any further action taken from my input devices

Is there a way to calculate the distance between the center and the mouse cursor? Or anything that might help?

Hey, I guess you want to do something like freelancer, right? In that case I got something for you:

The first image shows you what the following BP will do. It takes a circle around the mouse cursor and maps every mouse location to it. Closer to the center, Output will be X=0, Y=0.
Mouse Right side of circle X=1, Y=0 | Mouse left side X=-1, Y=0.
Get close to the top of the circle, Output will be X=0, Y=-1; | bottom X=0, Y=1
Every value in between is normalized

Implementation

In BeginPlay we get the center position on the screen and find the radius for the circle (MaxMouseDistanceFromCenter).

Here in Tick, we calculate a vector from the center of the screen to the mouse location. Check the length of it and divide the length by the radius of the circle to get it mapped to values between 0 and 1.
All you have to to do is use the X and Y output and use it as you would with normal mouse or controller input.

Hope this help, I am here for any problems you might encounter.

Pardon me for asking this: would be this the right way to do it or I should advance further in research? To be honest it’s odd a little bit.

Sorry for my incompetence but I just barely start working in Unreal.

Just plug the output into MakeRotator X and Y directly every tick. No need for InputAxis stuff. X and Y of the normalized output are a replacement for InputAxis LookUp and LookRight.

Thanks a lot for your support! Now I can move to the next step.

DennyR I just hit a problem with the mouse cursor you helped me implemented. When I enter launch the script stop working. I guess I have to do something but i don’t know really what. Can you give me a hand?