Creating a simple character controler for topdown view

Hello everyone,
I decided that this was going to be the year I learn how to code. I’m trying to get a character to walk around on a surface to start, and maybe interact with some buildings. Maybe go in the building. But for now, just the moving is wrecking my brain.
I want the caracter to face the direction its going, and I’m using the lookAt function for that.
I created 4 empty game objects with the directions (NSEW) and attached them to inputs.
I then noticed the diagonals didn’t work, as far as facing them but the motion worked.
this is the code I have so far. is there a simpler way to get it to face the NE NW SE SW directions as well?

voidUpdate()
{
if(Input.GetKey(KeyCode.W)){
transform.Translate(0f,0f,mSpeed*Time.deltaTime);
model.transform.LookAt(RefUp);
}

if(Input.GetKey(KeyCode.S)){
transform.Translate (0f,0f,(mSpeed * Time.deltaTime )*-1);
model.transform.LookAt (RefDown);
}

if(Input.GetKey(KeyCode.A)){
transform.Translate ((mSpeed * Time.deltaTime)*-1,0f,0f);
model.transform.LookAt (RefLeft);
}

if(Input.GetKey(KeyCode.D)){
transform.Translate (mSpeed * Time.deltaTime,0f,0f);
model.transform.LookAt (RefRight);
}
}

You want the object to follow a mouse cursor, or simply rotate 90 degrees based on what button you press?

I want it to look in iterations of 45º depending what key. So Key S the char will look down. A will look to the left, but S+A will look diagonaly down and to the left

You should always put your code into code tags (under insert), to help readability, but you fornatted it surprisingly well. Depending on the way you move the character, there are easier and harder solutions, so I will give you a way, to mive things easier:

Vector2 movement = new Vector2()
//this will be used, to keep track of the movement direction
movement.x = Input.GetAxis("Horizontal");
//thid means, that if you press left, (or a)  you get -1 as the x value and 1 eith the right (or d)  pressed
movement.y = Input.GetAxis("Vertical");
//this is the same, except with up and down
transform.Translate(movement.x, 0, movement.y);
//This will work, hiwever you should look into rigidbodies, so the player wont pass trough walls

And because transform.LookAt works with vector3s, you can simply do transform. LookAt(new Vector3(movement.x, 0, movement.y) + transform.position);

Thank you for the reply. I did try and find a code tag but was unable to
Is the +transform.position a way to offset the look at location?

yes, because the transform.LookAt works with world space coordinates, and what I wrote, basically creates a vector2, that is when you’re looking left (-1; 0), and when looking forward and left, then (-1; 1), so I needed to offset it.

The code tag is easy to work with, you just press Insert/code, and then you paste your code into that window

That worked beautifully! thank you!

Well if I may abuse your generosity, I have a new problem now.
The player is inside a parent game object. I was able to rotate him using a public transform.
the player also has the animator controler, not the parent (Who holds the script).
and the animation as a isRunning bool. From the parent, how do I get to this bool?

Thank you, gorbit! I got that to work as well!!!