Creating a movement axis variable?

Hello, I am making a sidescrolling game, with 3 lanes of movement. If Z is up, and Y is forward, the three lanes will be on the X axis.

I am trying to have the character on the center lane, as default, call it the 2nd lane, but if you press W, the character will move to the furthest lane, call it the 1st lane, on the release of W, the character will return to the middle, default lane, the 2nd. The same can be said of pressing S and the character moves to the closest lane, the 3rd, and on release, the character moves back to the 2nd.

Now I am new, so I am learning blueprints, and so how I thought about doing this, is assigning a coordinate value on the X-axis to a variable, and calling that variable on pressing the correct input like this.

On press> SET (PlayerPosition)(X)>SET(Boolean) True

On Release>SET(PlayerPosition)(X)>SET(Boolean) False

With the first Set calling on both the PlayerPosition variable and CharacterMoment

So my question is, how do you set up a variable as a coordinate position, and would it be a float or integer?

Or am I going about this all the wrong way? :slight_smile:

Positions in Unreal are represented as Vectors, which are 3 floats, one for X, Y, and Z. Since you only want your player to move in one axis, you could use a float, and then use that to update the players position in that axis (eg, X for you example)

I looked at the Set Relative Location node, and I could set up the X-axis on that in the vector pins, if I split them, they do turn in to floats, now I can set a value on the X-axis, but the Y and Z axis then becomes static 0.0. So when I press W, my character moves to the right X-axis, but it also moves to 0.0 on the Y and 0.0 on the Z. So how do I now set a dynamic value on the Y and Z. I could promote the variable of the pins, but how do I have the variable call the character’s location?

You could use the Get Relative Location node to get the current relative location, split the output into X,Y,Z and plug the Y and Z in to your Set Relative Location, passing in the new Z value.

I will give it a try and see how it goes, thanks for the help!