i made multiple sprite animations. idelForward, idelBackward, IdelLeft, IdelRight. these idel animations were meant to change the direction the 2d character was facing. i made a java script and added the animation component and the animator component and added all the animations to the animation component. only the forward idel worked because it was the default animation but i got multiple errors saying that every animation needed to be set a legacy so i went into the debug window and changed the animation type from 2 to 1. now there are no errors but the forward idel stopped working and still no other animation works. bacically no animation is working yet there are no errors... honestly i have no idea what whent wrong. but i am fairly new to unity and even more unfamiliar to scripting. i watched a tutorial video to help me do my script. but it has been modifyed to fit my game. here is my script...
#pragma strict
function Update () {
//face up animation
if ( Input.GetKey ("w") ){
this.transform.GetComponent(Animation).animation.Play("idelBackward");
}
//face down animation
if ( Input.GetKey ("s") ){
this.transform.GetComponent(Animation).animation.Play("idelForward");
}
//face left animation
if (Input.GetKey ("a")){
this.transform.GetComponent(Animation).animation.Play("IdelLeft");
}
/face /right animation
if (Input.GetKey ("d")) {
this.transform.GetComponent(Animation).animation.Play("IdelRight");
}
}
↧