# Forward/Back input movement instead of Axis

I want to try and create an old school First Person dungeon crawler similar to old school games. An example is https://
Except replace clicking on screen prompts with WASD.

If the video is not obvious or you cannot watch the video the movement system I want to implement is:

• Pressing W or S will translate you forward/back X amount of units.
• Pressing A or D will rotate you left/right 90 degrees

Right now I have my rotation working

(I am aware that a lot of stuff can be connected so it looks cleaner, just haven’t done it yet. However if you know a more performance efficient way to do it I should know, that’d be helpful.)

However my forward/back blueprint is not working

The issue that comes up is weird results coming from actually pressing the input. The timeline goes from 0 to 40 and the start location is at 100.

If I press W 4 times it’ll go

1. X = 100 (intended: 100)
2. X = 240 (140)
3. X = 380 (180)
4. X = 520 (220)

The other issue that will show up later is the way my blueprint is set up now, if I rotate my camera 180 degrees I will essentially move backwards if I press W. Is there a better solution than making a branch with 4 variables for each rotation (90, 180, 270, 0) and change X/Y depending on which variable is checked?

I think the W going backwards is because you use relative rotation. So in terms of world rotation you haven’t turned, hence pressing forward will go backwards.

Look at using Set World Location, or Add World Offset instead.

I manged to solve my ridiculously increasing speed issue (I replaced get world location with get relative transform, breaking the transform to get location and use that value.

Now I just have the issue with it not moving the direction I want when I press W. I’ve tried world location and world offset which both didn’t work, however I adopted world rotation over relative. Right now my current solution is very silly but works. (I currently have a branch checking which direction I’m facing and I do different operations based on it)

if my worldRotation is -1 to 1 it transforms X positively by 280.

if my worldRotation is 89 to 91 or -269 to -271 it transforms Y positively by 280.

if my worldRotation is 179 to 181 or -179 to -181 it transforms X negatively by 280.

if my worldRotation is -89 to -91 it transforms Y negatively by 280.

Doing something like would, would I expect any performance problems?

Assuming this only happens on key presses, I 't think it would cause any performance drama.

GetActorForwardVector and GetActorRightVector

E: I see you are moving a FirstPersonCamera around manually. I was doing similar with a 3rd Person Camera and found it awkward. It is much easier to use a Pawn(or Character) class to deal with movement in the world. You can then attach a camera to that class and set the relative location (eye height for example). This is how the editor camera works for example.

Are you using a timeline or matinee for this? The blueprint looks odd to me:

I 't recommend using “SetRelativeLocation” as this sets a local position I believe. You’ll want to inerpolate between your new location and your old location to get a smooth transition but if you 't care about that, setting world location is fine. The other issue you’re going to have is setting your location relative to your camera orientation.

Should look more like this i think: (wasn’t able to test this one)

Basically:

• Get actor rotaion
• From rotation get forward vector
• Multiply forward vector by distance
• If moving backwards, multiply distance by -1 first
• Add vector result to current location (captured after “set location” of course)

This does not solve rotation, but that is handled by:

• Receive input
• Get actor rotation
• Add 90 or -90 rotation on axis to character rotation
• Set character rotation

Hope that helps! Good luck!