- Home /
animation error no animation called "Idle"
i saw this script on a video and it worked perfectly for him but not for me. when i do it, i get an error saying: The animation state idle could not be played because it couldn't be found!Please attach an animation clip with the name 'idle' or call this function only for existing animations. how do i fix this?
this is the script:
#pragma strict
var rotationSpeed : float = 10;
var walkSpeed : float = 7;
var gravity : float = 50;
private var yRot : float;
var body : Transform;
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
var vertical : Vector3 = transform.TransformDirection(Vector3.forward);
var horizontal : Vector3 = transform.TransformDirection(Vector3.right);
var height : Vector3 = transform.TransformDirection(Vector3.up);
if(Input.GetAxis("Vertical") || Input.GetAxis("Horizontal")){
animation.CrossFade("walk 001",0.2);
controller.Move((vertical * (walkSpeed * Input.GetAxis("vertical"))) * Time.deltaTime);
controller.Move((horizontal * (walkSpeed * Input.GetAxis("Horizontal"))) * Time.deltaTime);
}else{
animation.CrossFade("idle",0.2);
}
if(Input.GetAxis("Mouse X")){
yRot += 10 * Input.GetAxis("Mouse X");
}
transform.rotation = Quaternion.Euler(0, yRot, 0);
controller.Move(height * gravity * Time.deltaTime);
}
function LateUpdate(){
// Rotate the Character to match the direction he/she is going
if(Input.GetAxis("Vertical") == 0){
if(Input.GetAxis("Horizontal") > 0){
body.localEulerAngles.y = 180;
}else if(Input.GetAxis("Horizontal") < 0){
body.localEulerAngles.y = 0;
}
}else if(Input.GetAxis("Vertical") > 0){
if(Input.GetAxis("Horizontal") > 0){
body.localEulerAngles.y = 135;
}else if(Input.GetAxis("Horizontal") < 0){
body.localEulerAngles.y = 45;
}
}else if(Input.GetAxis("Vertical") < 0){
if(Input.GetAxis("Horizontal") == 0){
body.localEulerAngles.y = -90;
}else if(Input.GetAxis("Horizontal") > 0){
body.localEulerAngles.y = -135;
}else if(Input.GetAxis("Horizontal") < 0){
body.localEulerAngles.y = -45;
}
}
}
please can somebody tell me how to fix this?
Do you have an "animation" component added to your character and does that animation component have the "idle" state listed in 'animations' list dropdown ?
i animated it in blender soo.... i dont get the dropdown
I think then it is because you have not set the animation component on your character. Select your character in the hierarchy view. Check if you have 'Animation' added. If not then : Click 'Add Components'->$$anonymous$$iscellaneous->Animation and add it. Then you will notice in the animation component in the inspector a dropdown called "animations" select that and include all you character animations in the list.
Hope this helps ...
i did that but it still doesnt work ps. sorry its been so long
Your answer
Follow this Question
Related Questions
AnimationEvent has no function name specified! 6 Answers
Timeline error 1 Answer
Animation Event issue what am I doing wrong here 2 Answers
C# Enum for Animation Issue 1 Answer