How to move character depending if my mouse goes up or down?

Hi,

I have a dragon that flies but I want it to fly up if I move my mouse up and goes down when it detects that now I am moving my cursor down.

So now I have it working with 2 keys, F key to go up and V to go down, but I want it to be detected automatically.

How can I do that?

Thanks!

you could get the screen position of the mouse and check on tick/timer if its higher or lower than its previous position

More information on the effect you’re trying to achieve would be useful.

For instance, where is camera in relation to the dragon? Is a first or third-person character riding it with the camera following behind? Or is dragon moving independently of camera ( as in, like in a side scrolling game, or some non-player character you’re commanding remotely)?

And how should the downward motion occur? Should dragon rotate and dive towards the mouse input, or just move straight down as if it’s being dragged and dropped somewhere?

It is a third person camera, I have a character controller and inside the character I have my mesh which is my dragon and my camera.

The dragon starts moving once I click my mouse, so now I have it moving left and right correctly, but not up and down.

Maybe it is better with images:

So this is my BP so far, it works fine on X axis, but in Y it goes UP but the camera is not following my mesh, so maybe I am not doing it correctly.

So here it’s what happens if I move up, the camera keeps down. If anyone has some good tutorial I can follow …it would be really helpful since I just found airplanes tutorials and didn´t work as I wanted to :c
image

Easiest way to get third person flying is something like this:

Plug the mouse y value from the IA Turn triggered exe pin into an Add Control Pitch Input node though so the camera will look up.

Just call start flying event (or change it to a function) whenever you’d like flying to kick in. Like if you hit jump and falling is true.

Then call stop flying with the On Hit event of character to make them land when they collide with something. With UseControllerDesiredRotation and UseControllerPitch both set to true, if you aim camera up, moving forward will fly up.

Should look something like this when flying. Ignore the de-synced rider animation and, well, the fact it’s a pig, not a dragon:

Using raw mouse input to add move input up and down could get wonky real quick when the mouse gets to edge of screen. If you really want to do it this way though, add a branch after you add yaw input in the IA Turn event to check for flying, then feed the y from event into an add movement node with up (or maybe down depending on how you configured the axes) as the vector:

1 Like

Thank youuuuuuu!!!