character turning around.

Right now im using the fpsWalker script and adjusted it to use for a 2.5d type game. I was just wondering if its possible for my character when i hit A to go backwards insted of just going backwards. For my character to 180 and be facing that way and then turn back when D is hit.

Use this:

function Update () {
    if (Input.GetButtonDown("Fire1")) {
        transform.eulerAngles = Vector3(0,180,0);
    }
}

to turn your character around.

I couldnt get that to work.....here is my code for moving ... where would i put it

//Moving arond var speed = 6.0; var jumpSpeed = 8.0; var gravity = 20.0; //shooting var bullitPrefab:Transform; //dying private var dead = false;

//getting hit //static var gotHit = false;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "fallout") { dead = true; // sub life here //healthcon.LIVES -=1; } }

private var moveDirection = Vector3.zero; private var grounded : boolean = false;

function FixedUpdate() { if (grounded) { // We are grounded, so recalculate movedirection directly from axes moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, 0); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed;

    if (Input.GetButton ("Jump")) {
        moveDirection.y = jumpSpeed;
    }
}

// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;

// Move the controller
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) != 0;

if(Input.GetMouseButtonDown(1)) {

var bullit = Instantiate(bullitPrefab, GameObject.Find   
    ("spawnPoint").transform.position, Quaternion.identity);
bullit.rigidbody.AddForce(transform.right * 3000);

} }

function LateUpdate() { if(dead) { transform.position = Vector3(-55,7,0);

            dead = false;
        }
        }

@script RequireComponent(CharacterController)

Just add

if (Input.GetKeyDown (KeyCode.a)) {

 var translation = Time.deltaTime * 180;

 transform.eulerAngles = Vector3(0,translation,0);

}

into a function update. I think....