# Rotating A Character 180 Degress

So, I'm working on a 2D platformer. But, I'm editing the FPSWalker script to fit my needs. I want the character to rotate 180 degrees on the Y-Axis depending on which direction he's moving. How could I do this? I know that their's transform.rotate, but my brain is trying to comprehend..

``````  var playerSpeed = 15.0;
var jumpSpeed = 15.0;
var gravity = 20.0;

var AntiBunnyHop = 1;

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

function Start () {
jumpTimer = AntiBunnyHop;
}

function Update () {
if (Input.GetButton("Attack")) {
}
if (Input.GetButton("Attack 2")) {
}
transform.position.z = 0;
}

function FixedUpdate () {
if (grounded) {
//Haha, your on the ground you loser.
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0 , 0);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= playerSpeed;

if (!Input.GetButton("Jump"))
jumpTimer++;
else if (jumpTimer >= AntiBunnyHop) {
moveDirection.y = jumpSpeed;
jumpTimer = 0;
}
}

// 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;
}

@script RequireComponent(CharacterController)

``````

Use this:

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

``````