Can I detach the mouse?

I’d like to be able to use the mouse for point/aiming, as well as movement, all dependant on how close to the edges of the screen you get. Half Life 2 used this method for VR aiming, and I really need the same thing as I think it’s the best method so far. Unfortunately, I can’t seem to figure it out. I need the Pitch mouse movement to only effect the aiming, and the Yaw to effect the aiming until you get within a certain distance, then move the view as well.

If I can use the mouse for aiming without moving the player, I think I could also use this for a 3D in-game GUI as well. Then use that interface to allow the player to control where the deadzones are. I could do alot with it, if I could just get past this hurdle. Any ideas?

Late answer: I don’t know the “unreal” way to do this, but my first idea is to:

  1. Fetch the viewport size
  2. Set a percentage of that size that will be the threshold for how close to the edge of the screen you have to bring the mouse cursor before it starts to rotate your view at all.
  3. Every Tick, instead of putting the mouse axis input values in to set the rotation of your camera or pawn directly, run it through a calculation that checks whether your mouse is close to the edges. For example, if the mouse’s Screen Position (there is a blueprint node that can get that) divided by the viewport’s X size gives a quotient less than the percentage threshold you set in the previous step (or gives a quotient which is greater than 1.0 minus the threshold, for the right side of the screen), then branch true to proceed further with calculating how far to rotate on this tick. Do likewise but in a separate calculation, for rotation on the vertical axis using mouse Y and screen Y size.
  4. If you are adding to the rotation, then how much to add to it can be determined by the difference between the threshold percentage (value between 0.0 and 1.0 representing 0 percent and 100 percent respectively) and the quotient you found for the mouse screen position vs viewport size on that axis. Use Map Range node putting in the min and max of the inputs as the smallest and largest difference it can be (so if your threshold value is 0.2, then smallest is 0.0 and largest is 0.2, and then the outputs would be 0.0 min and 1.0 max. This will give you a percentage of how fast to rotate.
  5. Multiply this turning amount by a Turn Speed variable (or pitch speed, for the vertical axis, or call them Sensitivity maybe, like if you wanted it to be adjustable) and by Delta Time from the Tick event node. That is the amount to feed into the the Add Rotation (what’s it called, Actor Add Rotation?).
  6. Aiming up and down usually isn’t the same as rotation the whole character, so you may want to do something different with the resulting value than change the pawn’s actual pitch. Probably just change the pitch of the pawn’s aim instead.

Doing it this way will make it turn continuously at the same rate based on how “hard” the user has pushed the mouse toward the edge of the screen, and only slows down or stops if they move the mouse toward center again, but based on the threshold value, gives them a dead zone where it doesn’t turn at all.

Alternatively you could base the threshold on distance from the center of the viewport (coordinates would be mouse screen or viewport position minus viewport size on each axis divided by 2 (or multiplied by 0.5) rather than distance from edges, if you want a more circular shaped dead zone.