- Home /
Transition Animations at end of current loop
Hi,
I currently have the following setup which allows me to transition between a number of animations on a static mesh (the code is probably a bit shonky, but its mostly working for me as-is).
using UnityEngine;
using System.Collections;
public class flow_Control : MonoBehaviour {
public string CURRENT_STATE = "straight";
// Use this for initialization
void Start () {
animation.Play ("straight_flow");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.Space)) {
if (CURRENT_STATE == "straight") {
animation.PlayQueued ("S_to_T_transition", QueueMode.CompleteOthers);
animation.PlayQueued ("turbulent_flow", QueueMode.CompleteOthers);
CURRENT_STATE = "turbulent";
}else{
animation.wrapMode = WrapMode.Default;
animation.PlayQueued ("T_to_S_transition", QueueMode.CompleteOthers);
animation.PlayQueued ("straight_flow", QueueMode.CompleteOthers);
CURRENT_STATE = "straight";
}
}
}
}
The straight_flow and turbulent_flow animations are both looped. What I'm wanting to do, is interrupt the loop, waiting for the current cycle to finish before running through the transitional animation into the second state. Currently though, if the animations are set to loop, the transition never happens. If they're set to once or default, everything behaves as I'd expect.
How would I go about queuing these animations to play once the current loop-cycle has finished?
Your answer
Follow this Question
Related Questions
How can i make this animation play only once? C# 1 Answer
How can i animate my Object? (bones available) 1 Answer
Smooth loop animations? 4 Answers
How to play animation once in Input.GetMouseButton 1 Answer
Coroutine to WaitForSeconds() on enemy AI causing all instances of AI to pause. Solution? 1 Answer