# How to rotate and move the camera when a specific key is pressed?

**URL:** <https://forums.unrealengine.com/t/how-to-rotate-and-move-the-camera-when-a-specific-key-is-pressed/445814>\
**Category:** Cinematics & Media\
**Tags:** rotation, unreal-engine, Blueprint, question, key-bind\
**Created:** [March 23, 2019, 2:09am UTC](https://forums.unrealengine.com/t/how-to-rotate-and-move-the-camera-when-a-specific-key-is-pressed/445814 "2019-03-23T02:09:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SalamanceYT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SalamanceYT](https://forums.unrealengine.com/u/SalamanceYT)\
**Post date:** [March 23, 2019, 2:09am UTC](https://forums.unrealengine.com/t/how-to-rotate-and-move-the-camera-when-a-specific-key-is-pressed/445814/1 "2019-03-23T02:09:46Z")

</div>

What I’m after is when I press A or D the camera will rotate 90 degrees left and right but when looking at a specific place and W is pressed the player will move forward to a specific position and stop, I don’t want the camera to be stiff either, when moving forward the camera needs to be animated so it moves around and rotates. Here are a few examples I made in Blender:

Each time A is pressed: [Screen capture - fd065047ac6cf73a76eccbe43b38a5a6 - Gyazo](https://gyazo.com/fd065047ac6cf73a76eccbe43b38a5a6)

Each time D is pressed: [Screen capture - 1c104e665bfc8d7924cc60634402ed24 - Gyazo](https://gyazo.com/1c104e665bfc8d7924cc60634402ed24)

Each time the player is looking in this direction and W is pressed: [Screen capture - fd0cc6d7d13b985efd3394b4d3979cf6 - Gyazo](https://gyazo.com/fd0cc6d7d13b985efd3394b4d3979cf6) (after this the player should be able to turn around again using the same A D mechanics and move back to the beginning by pressing W)

What the camera is animated like when moving: [Screen capture - 47d4b7a23b37ae860713cdf217ba650e - Gyazo](https://gyazo.com/47d4b7a23b37ae860713cdf217ba650e)

---

<div class="post-metadata">

**Author:** ![Elou44](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/elou44/32/738751_2.png) [@Elou44](https://forums.unrealengine.com/u/Elou44)\
**Post date:** [March 23, 2019, 5:54pm UTC](https://forums.unrealengine.com/t/how-to-rotate-and-move-the-camera-when-a-specific-key-is-pressed/445814/2 "2019-03-23T17:54:06Z")

</div>

Hi SalamanceYT,

Here is the solution I came up with to implement _Dungeon Crawler_ movements, hope it fits your needs :

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/7/28771dfd7fee79d13049c5d003a3117ab1a1d24a.gif)

I Migrated the _FirstPersonCharacter_ from the demo project _FirstPerson_ as a start point but if you already have a Character in your project you can use it. Also I deleted everything that was already set up in the _Event Graph_. Now, let’s begin :

- Create 3 **Action Mappings** : _MoveForward_, _Rotate90L_, _Rotate90R_ in the Editor settings.

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/c/15c688c4a0ed283d197adb4b998716735a100d2f.png)

- **Movement logics** (inside your Character class) :

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/6/ae6e1b0e8af146ac078175604cb0fcfdfa5373a8.png)

Create a Timeline to have control over the movement fluidity and duration (Right click then type ‘_Add Timeline_’ and double click on it to edit). To smoothen the curve, you can right click on the key and select ‘_Auto_’ as the interpolation method.

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/6/0/c6006fbb868df80801a9ee360eeeecf5106e3791.png)

- **Rotation logics** (inside your Character class) :

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/2/bf2417a9acc5b0694c9ffa051a04de2b3f3736a4.jpeg)

Create a Timeline to have control over the rotation fluidity and duration (Right click then type ‘_Add Timeline_’ and double click on it to edit).

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/a/3/8a34de8b256235adff745157260579809166a2ea.png)

Feel free to ask questions if something is unclear.

Cheers.

---

<div class="post-metadata">

**Author:** ![SuprSaiynMusashi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SuprSaiynMusashi](https://forums.unrealengine.com/u/SuprSaiynMusashi)\
**Post date:** [June 1, 2020, 12:17am UTC](https://forums.unrealengine.com/t/how-to-rotate-and-move-the-camera-when-a-specific-key-is-pressed/445814/3 "2020-06-01T00:17:08Z")

</div>

This was very helpful as I’m trying to make a dungeon crawler on a grid myself! Few more things I’d like to able to do tho:

How do I increase the size of a single step? I tried messing with the timeline duration and final value but so far, my character always takes 100 unit steps.

I also want to set it up such that my character will keep stepping while the button is held down. Anyone know how to arrange that?
