- Home /
How can I properly integrate rotation to a character?
I've got this basic movement script
var speed = 6.0;
private var moveDirection = Vector3.zero;
function FixedUpdate () {
moveDirection = Vector3(0, 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
}
@script RequireComponent(CharacterController)
I've been trying to add rotation by myself to it and I'm kind of stuck here, and I checked the documentation and I got it to rotate but it would not rotate 360 degrees, at certain point it just stopped, I looked on other scripts and what I found was this:
var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
it kind of worked but it didn't integrate that well with the other part of the code, so my question is, how can I integrate rotation to it, and besides that, a good tutorial about movement for unity would be nice, thanks for reading.
Comment