The animation transition, which is activated when the ‘Activating’ Boolean is true and the ‘Deactivating’ Boolean is false, is firing at the same time as the .SetActive(), instead of before the Thread.Sleep(1400), why is this?
Hello, ThatAussieCoder11. I’ve passed on your message to the Animation developers and they responded with this:
It’s impossible to tell from that script alone. Is the Animator execution dependent on culling? Is it out of frame before the camera is changed? Nevertheless, transitions are not triggered when properties are set; they are triggered when the Animator executes.
I’ll be waiting for more information from you. Thanks in advance!
You’re sleeping the thread. If this is executing on the main thread, you’re basically halting the engine for 1.4 seconds and make it do pretty much nothing. If this is off the main thread, you’re using the scripting API from a non-main-thread and should be seeing errors.
To let time pass, return control back to Unity. For example, via using a coroutine instead of sleeping the thread.
The fact that SetActive leads to a change in the animator state is because its wake up code will run (I assume the Animator component is somewhere in the CameraUI hierarchy) as part of its GameObject being activated.
public IEnumerator TabletActivate()
{
tabletAnimator.SetBool("Activating", true);
tabletAnimator.SetBool("Deactivating", false);
// Pass control back to Unity. However, if the Animator is indeed on a GameObject that is
// inactive, you will still not see an effect from this until you activate it.
yield return new WaitForSeconds(1.4f);
CameraUI.SetActive(true);
SetCam(defaultCamera);
staticScript.staticEnabled = true;
}