Hi!
I’m trying to animate a 2D “You lose” Image (UI=>Image).
I’ve created the animation with the Animation window, and it works if I tick ‘loop’.
However I want it not to be playing and then play when I lose a game.
I can’t seem to make “anim.Play(“ScaleUpAnim”);” work in the following script. While a anim.stop() works fine.
nb : This code has my play in the update fonction with a delay of 2s, for testing purposes.
using UnityEngine;
using System.Collections;
public class EndGameAnim : MonoBehaviour {
public bool isWin;
public static Animator anim;
private float tempDelay = 2;
private float beginTime = 0;
public void Start () {
print("Start anim");
anim = GetComponent<Animator>();
print("Anim = " + anim);
}
public void Update () {
if (Time.time >= tempDelay) {
print("post sleep");
anim.Play("ScaleUpAnim");
}
}
public static void scaleUp () {
// print("Anim 2 = " + anim);
// anim.Play("ScaleUpAnim");
}
}
Screenshots of my inspector linked.
I’ve tried to put “Lose” as the string in play, but it’s not working either.
Any ideas ?!
,Hi!
I’m trying to animate a 2D “You lose” Image (UI=>Image).
I’ve created the animation with the Animation window, and it works if I tick ‘loop’.
However I want it not to be playing and then play when I lose a game.
I can’t seem to make “anim.Play(“ScaleUpAnim”);” work in the following script. While a anim.stop() works fine.
nb : This code has my play in the update fonction with a delay of 2s, for testing purposes.
using UnityEngine;
using System.Collections;
public class EndGameAnim : MonoBehaviour {
public bool isWin;
public static Animator anim;
private float tempDelay = 2;
private float beginTime = 0;
public void Start () {
print("Start anim");
anim = GetComponent<Animator>();
print("Anim = " + anim);
}
public void Update () {
if (Time.time >= tempDelay) {
print("post sleep");
anim.Play("ScaleUpAnim");
}
}
public static void scaleUp () {
// print("Anim 2 = " + anim);
// anim.Play("ScaleUpAnim");
}
}
Screenshots of my inspector linked.
I’ve tried to put “Lose” as the string in play, but it’s not working either.
Any ideas ?