Hou Use Mouse Dx and Dy to create character-relative movements?

Dear Friends at Epic,

#Background

In my situaton below, the character is always oriented to the rotation of the player controller’s view, so character rotation = player controller view rotation


I have a programming question here

I am trying to make a sword swinging mechanic where the player’s mouse directly controls the character’s arm

I am using a blend space where yaw and pitch are set based on the mouse dx and mouse dy.

It works PERFECT when the character has a rotation of yaw 0 in world space.


#Obtaining Mouse Dx and Dy from PC

** I am obtaining Mouse Dx and Dy here:**

APlayerController::GetInputMouseDelta(MdeltaX, MdeltaY);

The problem I am having is that the Mouse Dx and Mouse Dy are not relative to current orientation of the screen, but rather apparently somehow to a world axis or some fixed axis of another kind

which means that the values of mouse movements are not relative to the orientation of the player controller’s view

which means that when I swing the warrior’s arm with my mouse and it works perfectly when warrior and pc view are facing world rotation yaw 0,

well this does not work when warrior is facing at a rotation of yaw = 90, or 180, or any other angle


#Make Mouse Dx and Dy relative to Character / Current Player Controller View?

Is there a way I can convert the Mouse Dx and Dy to be relative to the current camera view / player controller view ?

Thanks for UE4! It’s awesome!

:slight_smile:

Rama

Hi Rama,

Thank you for your question. I believe you could accomplish this by using GetControllerRotation to get the exact way the character is facing, then calculate the changes by using the Mouse Dx and Dy. Please let me know if that helps you with finding the correct rotation.

Cheers,

Alexander