Hi there
I have 4 objects with below test script. The goal is that they start a simple scale animation with simple offset - of random number between 2 and 3 seconds.
But it appears the animator is paused without any decimal in float in the scaleWaitSec in this script? like it was using int instead of float.
I tried with few different options - also setting the variable as public float - and setting it in inspector - but still it does not play correct = the animation starts after either 2 or 3 seconds - not 2.5 or 2.4 etc.
Any help is very apprecierede.
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using System.Collections;
//using System;
public class AnimateTile : MonoBehaviour {
Animator anim4;
float scaleWaitSec;
int scaleHash = Animator.StringToHash("scale_but");
int scaleHashRev = Animator.StringToHash("rev_scale_but");
// Use this for initialization
void Start ()
{
scaleWaitSec = Random.Range(2.1F, 2.9F);
anim4 = GetComponent<Animator>();
StartCoroutine(playAnimation(scaleWaitSec, anim4));
}
// Update is called once per frame
void Update () {
}
IEnumerator playAnimation(float time, Animator aob)
{
yield return new WaitForSeconds(time);
// Insert your Play Animations here
aob.SetTrigger(scaleHash);
}
}