Download

How to rotate the game world in-game.

I’m relatively new to UE4 and Blueprint, but is there anyway to rotate the world in-game using a player input?

Basically I’m attempting to rotate the game world only along the axis’ to guide a cube through tunnel-like levels getting from point A to B. It’s very early at the minute and I currently only have a small system that allows me to rotate an object on the pitch but it seems like there should be a much easier way.

Is it possible to change the flow of gravity on the fly in-game ? That seems like a much easier solution.

Arbitrary gravity is on the way in a future engine update, but as of now is not possible.

The best way to do this would be to make the environment a child of a movable base object that you would rotate with player input, taking the rest of the world with it.

Unless you want to rotate in perfect increments, timelines are probably not the best way to go about doing this. Just make the base object receive input and set its rotation to be its current rotation + input.

Cheers Jared, yeah I do want to move in perfect increments ala Fez. I’ll try it out and see if I can get it working.

Oh! Well in that case, timelines can do what you want. I’d recommend using Lerp (Rotator), with From being your base object’s current rotation and To being the same but with Pitch incremented. The Timeline would then interpolate between 0 and 1 over time instead of interpolating the pitch value directly. This way you can get rid of the gate and have just a single timeline. The output float value of that timeline would plug into the “Alpha” input on the Lerp function. The output of the Lerp would set actor rotation on the base object.

You can also check our free plugin, iTween for UE4 here: https://forums.unrealengine.com/showthread.php?33992-Open-Beta-Procedural-On-the-Fly-Animation-in-UE4-iTween!

The advantage to using iTween over Lerp is a plethora of built-in easing functions to give your transitions a little more jazz and a bevy of extra options like delay, loops, messaging between blueprints and interpolating over time or by speed. Plus video tutorials!

Okay I think I’ve done what you suggested and it’s rotating fine but at the minute as soon as I try and rotate another increment of 90 degrees to 180 of the original starting point, it starts the animation over again and plays the first 90 again rather than continuing the rotation further. Any suggestions?

4m6zAIS.png

Thanks.

Aw, I’m bummed you didn’t opt to use iTween :slight_smile:

You’re close, but you’ll want to use the Lerp (Rotator) node specifically, not Lerp for floats. Try it like this:

Untitled-2.png

Hi, sorry only just got access to my PC again after the weekend. The cube which I’m using as my example shape is basically just spinning erratically now for some reason. Any suggestions ?

Capture.PNG

Hey, no problem. Yeah, the reason this is happening was an oversight on my part. Because you’re setting your rotation every time you’re getting it for Lerp’s A input, you’re sending a ton of conflicting instructions to the engine. That’s what’s causing the erratic spinning. I’m sorry about that.

Instead, when you press the B key, get your Actor rotation and store it in a rotator variable before the timeline. Use the new rotator variable as both Lerp’s A input and the rotator to which you add 90 degrees of pitch. In other words, have your new rotator variable replace “Get Actor Rotation” where it is.

Again, a mistake on my part. My apologies.

It works brilliantly initially but after the first two rotations it then starts to rotate backwards the way it came then after rotating back to the origin it starts rotating forwards again before repeating. Any ideas what I’ve done wrong? Capture.PNG