rotate and object on key pressed

Hi (noob :warning:)

Ok here it goes. When I press W key, I want an object to accelerate and increase its speed gradually to a max speed. Meanwhile I need it to rotate forward a little bit gradually accordingly. Now when I release the W key, I need it to lose speed gradually until it stops, and it rotates back to its initial rotation.

What do you suggest?

Hey @Ehsan_designer!

Check out this thread for increasing speed to max more gradually:

Additionally you can set your animation (so in this case rotation) according to exactly how fast you are going using blend spaces:

I hope the above contains the solutions you need!

Here’s a minimalistic Pawn approach:

Velocity magnitude mapped to pitch.

It will need extra work if the leaning is supposed to work in all directions.

2 Likes

thank you so much. I’ll look into this and keep you informed. (and actually yes I need it all for directions (e.g., wasd).

thank you. I’ll look into that and keep you informed

Ok I did the same thing, but I got strange results. You know we are working on a DJI drone model and as I press W, the drone moves forward obviously, and it rotates upward, mimicking a thrust movement (kind of like a helicopter). but the problem is when I press S to go backward it gets a glitchy rotation, but I need it to rotate back and have a negative rotation according to the backward trajectory of drone. What do think I can do to have some sort of a negative velocity?

Nornalise velocity to get direction, use direction to rotate and velocity magnitude to scale direction.

You could also clamp velocity and use it as is but it may not be as convenient in the long run.


Depending on how it’s really suppose to work/look and feel, you might be better off with a vector spring or actual physics sim.

Exactly, the feel is not ok; it is somehow unrealistic. I’ll check velocity spring and physics. thank you.

It’s hard to imagine how you want it to work. I can think of several ways of making a drone controller. Are we even getting physics involved here or you want to fake the rotation?

Try this, see if you like it:

You can do -45 to inverse it. Again, this is just a mere stub and more nuanced scrip is needed for a more plausible looking leaning. Multiplying the clamp by (or replacing it with) a curve may be enough.


If you need a proper, realistic & physically simulated drone movement, you will need to look into tunable PID controllers (not an UE related topic) - and then replicate the principle in the engine. Each propeller would need its own error correction.

1 Like

that’s really amazing and I can’t thank you enough. but Actually there is no “turn” in the project we are working on. As a matter of fact I just created an animation in 3ds max to mimic the exact movement that we are after:

as you see there is only move forward, backward, and a kind of strafe left and strafe right.

Right now we are working on the last solution you provided. I really appreciate your help. :heart: