hi
first week of learning unity and i decided to look into animation. i am able to get a working third person sphere with controls but im clueless as to basically turning that sphere into my blender character. my blender character also has animations and my goal is to press forward and my running animation starts. sorry for possible stupid question. thanks and have a nice day
Not a stupid question sir! Animations are what add life to your game. In order to play the animation when you are pushing a key. Create a new JavaScript and copy and paste this code into the script. Before you do this, make sure you model is using the Legacy Rig by selecting your model in the project and selecting the rig tab and editing the pop down. Then use you modeling program to figure out the start and end frame for each animation and entering them into the animations menu
var startInput = "w"; //Or whatever key you wish to use
//This function is called every frame
function Update () {
//This checks if you are hold down the forward key
if(Input.GetKey(startInput)) {
//This fades in the run animation if you animation is not named run, then change this line
animation.CrossFade("run", 0.1);
} else {
//This fades in the idle animation if you animation is not named idle, then change this line
animation.CrossFade("idle", 0.1);
}
}
Don’t be afraid to ask questions if I was not detailed enough
~ExplodingCookie
thanks for your reply and great message. your explanation was fantastic and it worked great. now i just need to learn to get the w key to actually move my character and play the animation. i just started to learn scripting today so im on my way. anyway thanks again and have a nice day.