- Home /
Fixing imported model axis.
For some reason my imported model (from Blender) has it's axis’s all messed up. I've applied a character controller to the model and everything seems okay, but when I play the game it flips the character from standing up to laying down. I'm pretty sure the script is fine, but I think the problem is in my model. What do you think? Is there anyway to fix this? Thanks
-Rov
Oh, thanks! What will happen if I need to animate the model? -Rov
Answer by aldonaletto · May 06, 2012 at 05:20 PM
The easiest way is to create an empty game object and child the model to it - this way you can adjust its rotation and pivot position in the Inspector. The empty object then becomes your main object, to which you will attach the CharacterController, camera, scripts etc., while the model becomes just a visual aid.
Oh, thanks! What will happen if I need to animate the model? -Rov
No problem: if the animation control script is attached to the main object, get the animation component in a member variable at Start like this:
var anim: Animation;
function Start(){
anim = GetComponentInChildren(Animation);
}
This will find the animation in the main object or in any of its children, and cache it in variable anim (what additionally improves performance). Use anim afterwards to control the animation:
anim.CrossFade("run");