- Home /
Delay and Twitching when using an empty state as Transition between multiple other states
Hey all, I'm trying to make a controller for events in Animator, where I use an empty state as a kind of master node. This makes it easier to check if the event part has been entered and thus reset the CustomID value(so it doesn't trigger more times then desired).
My problem here is:
1(Any state -> TransitionState): When I set a custom ID to something other then 0 it should enter the transition state. This happens, but usually with a delay, which I would like it not to have.
Settings:
Transition Duration - 0
Transition Offset - 0
Conditions:
CustomID != 0
Exit Time == 0.00
2(TransitionState -> EventState): When I am in the empty transition state and it transitions over to one of the event states more then once, there seems to be a twitching(trying to transition from none to an animation)even though I have said there should be no tweening/overlapping transition. This is especially noticeable when an event is played multiple times.
Settings:
Transition Duration - 0
Transition Offset - 0
Conditions:
CustomID == 1
I have tried with an animation in the transition state too, but it doesn't seem to make any difference. Maybe it is something I have misunderstood, if so please tell. :)
Answers would be highly appreciated.
This is the animator(Red numbers are CustomIDs) and the code used if it helps:
public void SetCustomState(CustomState state, float resetAfterSeconds = 0)
{
animator.SetInteger("CustomID", (int)state);
StartCoroutine(CoroutineReset(resetAfterSeconds));
}
private IEnumerator CoroutineReset(float time = 0)
{
var stateName = Animator.StringToHash("Events.TransitionState");
var currentState = animator.GetCurrentAnimatorStateInfo(0);
while (currentState.nameHash != stateName)
{
currentState = animator.GetCurrentAnimatorStateInfo(0);
yield return new WaitForFixedUpdate();
}
if (time > 0)
{
yield return new WaitForSeconds(time);
}
animator.SetInteger("CustomID", 0);
}
Your answer
Follow this Question
Related Questions
Combining two animations to be one 0 Answers
Mecanim animator layers 0 Answers
What are those white curves in the animation transition panel - And can I read it in script? 0 Answers
Control normalized time of a transition with CrossFade() 0 Answers
Mecanim - How to use "Exit Time" for a state that uses negative speed (anim playing backwards)? 2 Answers