I want to apply a second animation to my GameObject (button).
Hey all,
i am making a small mobile application themed around the "Match the Pairs" game, and I want to add an extra animation to my button.
As it is atm, when you make a correct choice the button slides off the screen while rotating. I want to add some sparkles playing at the same time, in the starting position of the button.
here are some screen shots from Unity: http://imgur.com/a/CjOlj
TL:DR it cant fucking work!
and here is a script i wrote to test the animation.
using System.Collections;
using UnityEngine;
public class DebugScript : MonoBehaviour {
[SerializeField]
private GameObject selectedObject;
[SerializeField]
private Animator buttonTurn;
public Animation spark;
private string debugMe;
public void DebugMe(){
StartCoroutine(ButtonTurn ());
}
IEnumerator ButtonTurn() {
spark = buttonTurn.GetComponent<Animation> ();
debugMe = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.name;
if (debugMe == "Button") {
buttonTurn.Play ("ButtonTurn");
yield return new WaitForSeconds (3f);
spark.Play ("SparkleEffect");
buttonTurn.Play ("ButtonCorrectAnimation");
}
Debug.Log (debugMe);
}
}
Posted Aug 25, 2017, 12:38 PM UTC · edited
23