Unfortunately, the original screenshot is gone after last year’s forum update, and I didn’t save it or the project…
However, I had a few minutes to try to recreate the prototype, so here’s the 2022 version:
It’s still rough, but should be enough to illustrate the idea. This is still using the 3D sidescroller template, so all steps below are based on starting there.
-
I added two variables to store axis value and movement direction - these are needed later.
Axis value Forward tells me which way we should turn, and Movement direction is the vector along which the character moves. By default, this is -1 on the Y axis in the example project.
-
The trigger actor is a basic BP with just a collision box and an overlap event.
Below are the nodes on the trigger actor:
If it overlaps with the player character, the BP Interface fires on the character controller
Nothing fancy here…
- Back to the player controller, let’s add the movement direction update:
A) We take the movement direction vector variable and rotate it based on the axis input.
By default, moving right is +1, so we rotate the vector 90 degrees “forward”. If the character moves left, it would rotate it the other direction.
Since we set the vector, the change in movement direction is instant here, but you can improve this part with some blends or turning animations based on your preference.
B) Fire a custom event to rotate the camera (see below)
C) In this version, I kept “constrain to plane” turned on, so I’m just switching the constraint axis. In the default project, movement is along Y and the constraint axis is X. So if we see that the current axis is X, change to Y, and vice versa.
This works well for 90 degree turns and stops the character “floating” and getting misaligned during the turn, due to its velocity.
If you want to get more creative and add non-right-angle turns, or curves or whatever, you’ll have to improve this part…
- Camera turn is a simple lerp driven by a timeline:
“Update Camera” is the custom event that is called above.
A) Store current camera rotation
B) Calculate target rotation. 90 degrees is the default for this, and it rotates “left” or “right” depending on which way the character is moving.
C) Timeline is a simple float, 0.5 seconds long going from 0 to 1, which in turn drives the lerp between camera start rotation and the target rotation. Again, super basic and you can expand to your desires.
Too lazy to make a new video, but it functions pretty much the same as seen in my first reply.