public IEnumerator ManageAnimations() { int maxFrameRate = currentSequence.maxFrameRate; int minFrameRate = currentSequence.minFrameRate; float oldX = ri.currentXvelocity; while (true) { float xVel = ri.currentXvelocity; if (xVel < 0) { r.flipX = true; } else { r.flipX = false; } if (currentSequence != allSequences [idle] && cns.grounded && xVel == 0) { Cue(idle); } else if (currentSequence != allSequences [run] && xVel != 0 && cns.grounded) { Cue(run); } else if (currentSequence != allSequences [jump] && !cns.grounded) { Cue(jump); } oldX = xVel; if (currentSequence.speedSensitive) { int frameRate = Mathf.RoundToInt((Mathf.Abs(ri.currentXvelocity / ri.maxHorizontalSpeed) * maxFrameRate)); if (frameRate < minFrameRate) { frameRate = minFrameRate; } currentSequence.ChangeFrameRate(frameRate); } yield return(null); } }
public IEnumerator ManageAnimations() { int maxFrameRate = currentSequence.maxFrameRate; int minFrameRate = currentSequence.minFrameRate; float oldX = ri.currentXvelocity; while (true) { float xVel = ri.currentXvelocity; if (xVel < 0) { r.flipX = true; } else { r.flipX = false; } if ((oldX < 0 && xVel > 0)) { Debug.Log(walk); Cue(walk); } else if ((oldX > 0 && xVel < 0)) { Cue(run); } oldX = xVel; if (currentSequence.speedSensitive) { int frameRate = Mathf.RoundToInt((Mathf.Abs(ri.currentXvelocity / ri.maxHorizontalSpeed) * maxFrameRate)); if (frameRate < minFrameRate) { frameRate = minFrameRate; } currentSequence.ChangeFrameRate(frameRate); } yield return(null); } }