PlayerMovement

Hello everybody,
I’m having some trouble with making a script to make my player walk. What I’m trying to do is;

  • When you press W or Up-arrow you move forward
  • When you press S or Down-Arrow you move backwards
  • When you press A or Left-arrow you move to the left
  • When you press D or Right-arrow you move to the right

I’ve looked for some tutorials but I haven’t found any good tutorial in which they explain why it works. I want to understand what I’m doing and why it works so next time I need it I know what to do.

Thank you in advance.

Edit:
I’m using C#

Pressing keys

To move right or somethin:
transform.position = transform.position + transform.right

To move forward based on the camera:
transform.position = transform.position + transform.forward

To rotate

With this info I’m sure you can put it together quite quickly. (assuming you already have SOME scripting knowledge)