- Home /
Dependency sprite animation from the variable
There is sprite sheet animation. How to make it depend on a variable (float)? That is, if the variable # 1 is half the size of the variable # 2, then the animation will be half and so on. Sprites are something of a progress bar type. I tried this method:
"Rewind the clip to the desired frame, but since you can rewind only in time, then calculate how long one frame lasts, dividing the second by the fps value of the animation.For example, you have a clip of 30 frames per second, 1/30 =" one frame time "If you need to rewind to the fifth frame, then rewind the clip for the time 5 *"time of one frame".
And this is my problem:
public AnimationClip HeatUp;
public Animation anim;
//start
Time = 0.0166F;
//update
Time2 = MachineGun.CoolDown * Time;
int myInt = Convert.ToInt32(Time2);
GameObject.Find("MachineGun").GetComponent<Animation>().Play();
anim["HeatUp"].speed = 0; //cs:44
anim["HeatUp"].time = Time2;
Raises an error - NullReferenceException: Object reference not set to an instance of an object UIController.Update () (at Assets / Scripts / UIController.cs: 44), although there are no errors in the VS and everything pointed in the inspector.
Thanks.