I’m trying to recreate snake for learning purposes, and I can’t seem to get my snake to face the direction it’s moving.
private void Update()
{
if (Input.GetKeyDown(KeyCode.W)) {
_direction = Vector2.up;
} else if (Input.GetKeyDown(KeyCode.S)) {
_direction = Vector2.down;
} else if (Input.GetKeyDown(KeyCode.A))
{ _direction = Vector2.left;
} else if (Input.GetKeyDown(KeyCode.D))
{ _direction = Vector2.right;
} else if (Input.GetKeyDown(KeyCode.UpArrow))
{ _direction = Vector2.up;
} else if (Input.GetKeyDown(KeyCode.DownArrow))
{ _direction = Vector2.down;
} else if (Input.GetKeyDown(KeyCode.LeftArrow))
{ _direction = Vector2.left;
} else if (Input.GetKeyDown(KeyCode.RightArrow))
{ _direction = Vector2.right;
}
}
How can I make it were for instance, if I press W to go up, he not only moves up, but faces the up direction?