Help with moving Character using custom mouse controls

After countless hours of tinkering around in the blueprint for mouse movement ( axis, control, yaw, pitch ). I can’t quite get the results I am looking for. The default movement for the blueprint first person shooter has a basic aim/movement style. I am trying to get the movement using the mouse rather than ASDW. I would like to design the movement whereas if you move the ‘Mouse Cursor’ above the Crosshair in the middle of the screen I move forward, and when I move the ‘Mouse Cursor’ below the middle Crosshair I would then move backwards. As for looking ‘Left’ and ‘Right’ I want looking left or right to only make my pawn ‘Rotate’ at capped speed. In simple terms:

Mouse cursor top of the Crosshair--------->go forward.

Mouse cursor bottom of the Crosshair---->go backwards.

Mouse cursor left of the Crosshair---------->rotate left at max given speed.

Mouse cursor right of the Crosshair---------->rotate right at max given speed.

And if you would be such a boss :smiley: I would like to set the “Mouse cursor distance from crosshair” = speed (with a cap of course).
strong text
Example: Mouse Cursor 10% above or below middle crosshair = 10% of max speed.

Mouse Cursor 50% left or right of middle crosshair = 50% rotating speed.

(0% = Mouse Cursor at center of screen ----- 100% = Mouse Cursor at edge of screen).

Purpose of such controls is for a vehicle based shooter to help put this into perspective.

I am not asking anyone to do it for me. I would just like some insight on taking the right steps. If anyone could show me how to accomplish the mouse movement in 1 direction I could do the rest. I’m just trying to find a starting point, since the trial and error isn’t working. Appreciate any help :slight_smile:

Perhaps you could use mouse-over events. Event Actor Begin Cursor Over will fire when you mouse over the actor you put it in.

EG: make a new blueprint with a component you want to be the detection for when you mouse over it. Inside the graph, add “event actor begin cursor over” which will fire when you mouse-over it.

Is that what you were looking for? That’s just a small thought, if not then I’m not too sure, sorry.

You can call the “getMousePosition” function and do some Math, e.g. If you know the Screen Resolution you know that ScreenWidth/2 is the middle, then you can compare “getMousePosition” and ScreenWidth/2.
If MousePosition.x < ScreenWidth/2 then you know that the mouse is left etc.

trying to figure out how to use the get mouse position to work, not sure how to set up the math correctly for the scale value.

Assume your Screen is 1200 pixel wide, the midde is then 600. When your mouse Position is 200, you know that your mouse is in the left half of the Screen. You can then calculate the diffrence between the Mouse Position and the middle, e.g. 600-0 = 600 means your mouse is completely left, 600-500 = 100 is Close to the middle and 600-600 = 0 means it’s in the middle.


A few days ago I searched for some sort of this topic by myself. I didn’t find anything that really helped (stumbled over threads like this one) and spend a lot of time cracking my head about this, but finally it’s working! Therefore I want to share my “breakthrough” :wink:

It’s not exactly what you need, Jahmahn, but I think you can use the viewport math stuff for your mouse tracking.

What you can see in the graph below is basically a pawn fixed with its center to the mouse position. It moves to all edges of the viewport. I learned from the Fly BS Template that you need a Pawn instead of a Character because it can fly by default. Imagine the center of the viewport is (X= 0, Y= 0). Then the mouse location there would be (X= 640, Y= 360). You have to tell the actor to move in minus and plus direction because it doesn’t know the viewport… this guy would go anywhere. For instance the top of the screen is mouse (Y= 0) but actor (Y= 360), the very bottom is mouse (Y= 720) and actor (Y= -360).

And thank’s Yibby! You really helped my poor brain with the “half of the viewport math” :slight_smile: