How can I rotate objects in the game in perfect increments

Basically what the title says. I’m creating a game where the player has to help navigate a cube around tunnel-esque levels by rotating the tunnels upon their axis but only in perfect increments of 90 degrees.

At the minute this is where I am at although, I can rotate the cube forward on it’s pitch but after two rotations it rotates back 90 degrees and then just proceeds to act like a swing and just move back and forth between two increments. Has anyone got an easier way of accomplishing this or know how to rectify my mistakes and make the current way work ?

Thanks guys.

Hello DanSaxon,

You would be surprised as how common this is for someone to want to do in their game or cinematic. Getting something to rotate cleanly in a 360 degree motion can be a bit tricky. I would be glad to help though! Follow the steps provided, and see if it does not get your actor to rotate correctly!

I am going under the assumption you are rotating your actor via Matinee and you have already set up your movement track with that actor? If not go ahead and do that, and then follow the steps. Be sure your actor (cube) is set to “Movable” or else it will not be compatible with Matinee.

Another quick note. If you are attempting to move something in 90 degree increments so it makes a full rotated 360 degrees, you will want your timeframe in which you animate an even number. For example in the steps provided I set the matinee to be four seconds long.

From 0 to 90 degrees at the first second. From 90 to 180 degrees at the next full second. From 180 to 270 degrees at the third second. And finally from 270 to 360 degrees at the fourth second.

Steps to Follow

  1. Within your matinee set the “Snap” setting on so when making keyframes it snaps to the exact second. This just makes the process a bit easier.
  2. Now drag the little “red flag” that controls the overall time frame of your matinee to 4.0 seconds.
  3. With your movement track selected and being sure your actor is selected in the editor viewport, drag your slider over to 1.0 seconds. Press enter. Rotate your actor 90 degrees.
  4. Now drag the slider to 2.0 seconds. Press Enter. Rotate your actor 90 degrees.
  5. Drag the slider to 3.0 seconds. Press Enter. Rotate 90 degrees.
  6. To ensure your are finishing your matinee on the same original key frame and rotation, left-click on the very first key frame.
  7. Press “Ctrl + C” and drag your slider to 4.0 seconds (end of your matinee time frame).
  8. Press “Ctrl + V” to past the key frame at second 4.0
  9. Finally to the part that is making your actor rotate awkwardly. Click on your movement track and in the details panel, check the box that say “Use Quat Interpolation.”
  10. “This method of interpolation does not support winding, and is essentially linear between keyframes with no support for ease in/out. However, it is more robust and will always find the “shortest” route between two different orientations.”

Static Mesh Actor set to Movable

Details Settings for Matinee

Here is some great documentation more on how to use Matinee effectively.

Thank you and best of luck!