# Rotating A Character 180 Degress

 0 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")) { BroadcastMessage("Fire"); } if (Input.GetButton("Attack 2")) { BroadcastMessage("Fire2"); } 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) `````` more ▼ asked Jun 26 '10 at 07:32 PM Flipbee9 73 ● 19 ● 20 ● 25 SisterKy 2.5k ● 33 ● 42 ● 60 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

1 answer: sort voted first
 0 Use this: ``````function Update () { if (Input.GetButtonDown("Fire1")) { transform.eulerAngles = Vector3(0,180,0); } } `````` to turn your character around. more ▼ answered Jun 26 '10 at 07:49 PM e.bonneville 5.7k ● 100 ● 117 ● 165 Thank you. That's what I have been looking for. May 04 at 04:22 PM emrahsifoglu add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Topics:

x2248
x300
x79
x38

asked: Jun 26 '10 at 07:32 PM

Seen: 3986 times

Last Updated: May 04 at 04:22 PM