Movement doesnt work if I rotate my model

Hi!

I am having some troubles with my movement script. If I test it with a normal cylinder and a character controller mesh it works fine. The problem is, when I import my model to the scene, it changes the axis or something like that.

If I import and select all rotate values to 0 (as image): it works (of course the character is lied) http://img820.imageshack.us/img820/4668/sinrotaar.jpg

If I try to rotate the character in the position I want: http://img839.imageshack.us/img839/1065/sinrotar.jpg

It doesnt work. I think is something related to the axis, cos I only can Jump.

I add my movement script maybe I’m doing something wrong (I know my code is not the best, but I’m still starting and I have to learn a lot).

function Update () {
var controller : CharacterController = GetComponent(CharacterController);        
var right : Vector3 = transform.right * speed * Input.GetAxis("Horizontal");
var forward : Vector3 = transform.forward * speed * Input.GetAxis("Vertical");

	
right.y = moveDirection.y; // keep current vertical velocity
right.z = forward.z;  // z z
moveDirection = right; // but update horizontal velocity

//Doble salto
if (controller.isGrounded) {  //If the player is on the floor
	contadorsalto = 0; 			//Reset the counter
	moveDirection.y = 0;
	if (Input.GetButtonDown ("Jump")) {  //When press space
		moveDirection.y = jumpSpeed;  //Jump
		contadorsalto = 1; 			//Counter = 1
	}
} else {							//If the player is NOT on the floor
	if (contadorsalto < 2) {		// and the counter is less than 2 (only 1 jump)
		if (Input.GetButtonDown ("Jump")){  //When we press space
			moveDirection.y = jumpSpeed;  //Jump
			contadorsalto = 2;				//Counter = 2 so it won't enter again until player is in the floor 
		}
	}
}

moveDirection.y -= gravity * Time.deltaTime;

controller.Move(moveDirection * Time.deltaTime);

}

Thanks in advance!

Very common problem, i would get soo frustrated with this. All you need to do is set the pivot of your model so that Y points up, and Z points forward. In 3dsMax, you go to Affect Pivot Only and rotate it accordingly.

I didnt specify before, this will be done in the modeling program itself and not in unity. If youre not sure how to do this, do a “Search engine” search for your modeling program and how to change pivot of model.

Perfect, it works , thanks a lot!
Greetings