public TransitionPlayer(Transition t, float startingWeight) { keys = new Queue <Transition.TransitionKey>(t.Keys); previousKey = new Transition.TransitionKey(startingWeight, 0); currentKey = keys.Dequeue(); current = 0; IsFinished = false; }
public float Next(float timeDelta) { if (IsFinished) { return(currentKey.targetWeight); } current += timeDelta; if (current > currentKey.duration) { if (keys.Count == 0) { IsFinished = true; return(currentKey.targetWeight); } previousKey = currentKey; currentKey = keys.Dequeue(); current -= currentKey.duration; } return(Mathf.Lerp(previousKey.targetWeight, currentKey.targetWeight, current / currentKey.duration)); }