Hi, I’m trying to make a script which makes a creature evolve.
The new creature will have a new animation, so, how can I change the animation?
That’s the script:
using UnityEngine;
using System.Collections;
public class Evolution : MonoBehaviour {
public int soglia;
public Sprite primafase;
public Sprite secondafase;
public Sprite terzafase;
MouseButton tocchi;
// Use this for initialization
void Start () {
tocchi = gameObject.GetComponent<MouseButton> ();
}
// Update is called once per frame
void Update () {
if (tocchi.tocchi < soglia) {
gameObject.GetComponent<SpriteRenderer> ().sprite = primafase;
//CHANGE ANIMATION
}
if(tocchi.tocchi >= soglia){
gameObject.GetComponent<SpriteRenderer>().sprite = secondafase;
//CHANGE ANIMATION
}
}
}
How can I do this? Can I change the state of the animation controller or something like that?
(Sorry for my bad english)