So this is still my first week trying to write code for a simple game I thought of, so sorry if the question sounds dumb or is answered in documentation.
So I have this character that moves with WASD, but when I press something (in this case, button I) I want the WS to move him horizontally and AD to move him vertically. Basically swapping the vertical and horizontal.
EDIT: figured out I don’t need 4 types of floats. stupid me.
void Update () {
float vertical = Input.GetAxis("Vertical") * VerticalSpeed;
float horizontal = Input.GetAxis("Horizontal") * HorizontalSpeed;
Vector3 MoveDirection;
MoveDirection = new Vector3(horizontal, 0, vertical);
if (Input.GetKey(KeyCode.I))
{
MoveDirection = new Vector3(vertical, 0, horizontal);
}
But I have to hold the I for the swapping to work and that’s not what I wanted. GetKeyDown and GetKeyUp don’t help either.
Can anyone help me?