Keybinding for asset rotation according to angle snap
Is there a way to keybind rotation to a static mesh? For example, if I place a static mesh in my map, I'd like to press CTRL+R to rotate it clockwise via the Z angle according the the current rotation snap settings. So if the current rotation snap setting is set to 30, then every time I press CTRL+R, it'll rotate 30 degrees clockwise on the z-axis. I can't seem to find this setting or hotkey binding. Any thoughts? Oh, and it would also be nice to rotate counter clockwise as well.
Here's what you need to do in order to achieve what you want:
First, let's bind the input key Ctrl+R. From the top ribbon above Viewport, click on Settings > Project Settings. Once it opens up, go to Inputs which can be found on the left side panel, and add a new Action Mapping as shown in the picture below. Search for the key R and check the Ctrl as well. (I called my input event "RotateCube" but you can call it whatever that makes sense.)
Next, you need to make sure that the Mobility of your Static Mesh cube is set to Movable. Simply select your Static Mesh that is already put into the level, from the right side Details panel, under the transform, you can change its Mobility from Static to Movable. (If you don't do this your Static Mesh Actor will not move during gameplay.)
Finally, you need to define the movement functionality you want for your Cube in one of your blueprints. (You can do this in either PlayerController Blueprints, Level Blueprint, or any other suitable place that keeps your scripting and game logic neat and clean. I'm gonna show you how to set this in the level blueprints because that's easiest part where we can get a Reference to your Static object. Open the Level blueprint. You can find it from that top ribbon > Blueprints > Open Level Blueprints. Once that is opened, select your Static mesh, it will automatically gets highlighted in the World Outliner which is located by default on the right side of Viewport above Details Panel. Drag your object from the World Outliner into Level blueprint to get a reference to it. Once you get a reference to it in the Level blueprint, right click in any open area in your blueprint, and search for your binded input key which we Called "RotateCube". Get an event to it and set your blueprint as in the following.
That's all! Compile and save your Level blueprint. Click Play and whenver you press Ctrl+R your cube will rotate 30 degrees along the Z axis. Similarly you can bind a key to counter clockwise rotation and implemented in a exact same way.
Hope this answered your question.
answered Dec 27 '17 at 05:10 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here