Creating a side-scrolling trigger to switch plane movement

Hi all, need some help. I am using UE 4.8

My project is a 2.5D side-scroller. The player can move freely left and right, however at certain instances, I want the player to be able to move forwards and backwards, towards and away from the screen, while keeping the camera as it is. This could happen at a corridor for example.

Like this:

These are the movement inputs I have right now, concerning left-right and forward-backward movement.

70318-2.png

My question is: How the hell do I go about doing this?
I’ve scrapped planar locking, which is automatically activated in the side-scrolling blueprint example, but I can’t find anyway of locking/unlocking this within an actual blueprint. Unless I can create a function for it inside the character blueprint, but I have no idea how to do that.

I’ve been trying to use a box trigger to control the rotation, but I’m not sure if I should simply use the trigger in the character blueprint, or if I should create a new class to do this as I want the player to automatically be able to move down the corridor without having to “activate” the trigger with a button press.

Lastly, if I do create a new class, how do I make it rotate the player’s movement from X axis to Y axis and then call to this class within the character’s blueprint?

Thanks :slight_smile:

In you blueprint, get a reference node to the Character Movement component, then pull out the pin to access the functions to set the Constraint or Constrain Movement to a Plane, things like that.

Beyond that, it’s a little tricky to manage the triggering mechanism, because the player can enter the trigger volume from any direction, so how do you know which direction to constrain them to? You don’t know whether they’re going to go back the way they came or continue down the new direction.

So maybe one way you can handle it is to have a variable that is set to TRUE when the player is inside that trigger volume and cleared when they leave, and as long as it’s TRUE then they are not constrained to a plane but will on Tick be constantly Lerped toward one plane or the other, depending on whether their input is on the up/down axis or the left/right axis. Last input determines which plane to Lerp toward, which is also stored in a variable. Once they leave the volume, the lerping mode is turned off because the InsideTriggerVolumeForTurning or whatever you call it boolean will be FALSE, so they’ll continue to be constrained to the last plane they lerped toward.

Just an idea, not sure it will work but I would try it.

1 Like

I’m trying something like this at the moment, in the middle of figuring out the right constraint values needed to get the correct plane of movement needed for the environment. Haven’t tried lerping from one plane to the the next yet- just testing things out with a flip flop to get the initial behavior first. Thanks for the ideas!