Hello everyone,
Im trying to play an animation by pressing a button. Heres a 1 of I made the animation.
So, basically you see how it’s not playing even though Its running the command and how I made the animation.
What am I missing?
Yes, I’ve checked if the animation is legacy…
Thank you for your time.
////EDIT
I don’t like to put a whole lot of code but If you want to review it, I greatly appreciate it!
This is the script attached to the gui, it enables the button for the DPad.
public class DirectionPad : MonoBehaviour {
bool _downPressed;
Animation playerTempANim;
GUISkin mySkin;
// Use this for initialization
void Start () {
mySkin = GetComponent<newGUI>().mySkin;
_downPressed = false;
}
// Update is called once per frame
void Update () {
}
void FixedUpdate(){
if(_downPressed)
PlayAnimation();
}
void OnGUI(){
GUI.skin = mySkin;
if(GUI.RepeatButton(new Rect(Screen.width - (75 * 2) - 10, Screen.height - 75, 65, 65),"", "Dpad_ArrowD")){
// Debug.Log ("Pressing");
_downPressed = true;
}else {
// Debug.Log ("not Pressing");
_downPressed = false;
}
}
void PlayAnimation(){
if(playerTempANim == null)
playerTempANim = GameObject.Find("testAnimation").GetComponent<Animation>();
playerTempANim.Play("WalkDown");
Debug.Log ("Playing " + playerTempANim.animation);
}
}