x


Third Person Controller - help with increasing rotation speed

In using the script below, my model rotates very slowly when I press the left or right input keys. Does anyone know how to increase the rotation speed? Any help will be very appreciated!

private var walkSpeed : float = 1.0; private var gravity = 100.0; private var moveDirection : Vector3 = Vector3.zero; private var charController : CharacterController;

function Start() { charController = GetComponent(CharacterController); animation.wrapMode = WrapMode.Loop; }

function Update () { if(charController.isGrounded == true) { if(Input.GetAxis("Vertical") > .1) { if(Input.GetButton("Run")) { animation.CrossFade("run"); walkSpeed = 4; } else { animation["walk"].speed = 1; animation.CrossFade("walk"); walkSpeed = 1; } } else if(Input.GetAxis("Vertical") < -.1) { animation["walk"].speed = -1; animation.CrossFade("walk"); walkSpeed = 1; } else { animation.CrossFade("idle"); }

    // Create an animation cycle for when the character is turning on the spot
    if(Input.GetAxis("Horizontal") && !Input.GetAxis("Vertical"))
    {
        animation.CrossFade("walk");
    }


    transform.eulerAngles.y += Input.GetAxis("Horizontal");

    // Calculate the movement direction (forward motion)
    moveDirection = Vector3(0,0, Input.GetAxis("Vertical"));
    moveDirection = transform.TransformDirection(moveDirection);

}

moveDirection.y -= gravity * Time.deltaTime;
charController.Move(moveDirection * (Time.deltaTime * walkSpeed));

}

more ▼

asked Sep 30 '10 at 05:01 PM

Michael 2 gravatar image

Michael 2
45 4 5 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Just multiply the speed of rotation by something.

transform.eulerAngles.y += Input.GetAxis("Horizontal") * 2;

more ▼

answered Sep 30 '10 at 05:25 PM

Loius gravatar image

Loius
10.7k 1 11 41

Hey, that worked! Actually, I ended up multiplying the speed by 25. Thanks!

Sep 30 '10 at 06:43 PM Michael 2
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Topics:

x2167
x522
x357

asked: Sep 30 '10 at 05:01 PM

Seen: 1274 times

Last Updated: Sep 30 '10 at 05:01 PM