Sidescroller change the way charactor is faceing

I have a movement code for my charactor but when you change the direction you are walking I want the way the charactor is facing to change and match.

var speed = 3.0;

var JumpSpeed : float = 100.0f;
var gravity = 20.0;

function Update () {
var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.right);
var curSpeed = speed * Input.GetAxis ("Horizontal");
controller.SimpleMove(forward * curSpeed);


}

You can use transform.LookAt, or affect to transform.forward the direction you want to look at. However, you don’t change the direction in your example, only the speed and the sign. By the way, var forward = transform.TransformDirection(Vector3.right), that’s actually transform.right.