Mouse Aiming in UE4/ MP Top-Down

May 21, 2016·
Akbolat Sadvakassov
Akbolat Sadvakassov
· 1 min read

Hi-hi!

In this tutorial, I’ll show you how to implement mouse aiming in Top-Down games. In one of the previous tuts I showed a version for gamepad sticks.

P.S. It’s easier to implement than sticks.

Before starting, take a look at this post(Advanced Joystick in UE4 / Multiplayer Top-Down) until “Setting up Left Stick” item inclusive. Others isn’t necessary if your project doesn’t support gamepad.

In first, create a function in TopDownController. And set next:

We cast to TopDownCharacter through GetControlledPawn. Then we call SetControlRotation. It has an input named New Rotation. A value for this input we get from our actor’s (GetActorLocation) and mouse’s coordinates(GetHitUnderCursorByChannel), which connected to FindLookAtRotation.

Now in the EventGraph, connect our function to AddMovementInput.

The last step we need to do is – open TopDownCharacter, set true UseControllerRotationYaw checkbox in ClassDefaults and set false OrientRotationToMovement checkbox in CharacterMovementController.

And works in MP. Feel free to ask.

Link to project –> Google Drive


It’s a mirror from WebArchive