private void SetHandMovement(Animator animator, HandDirectionEnum direction, HandMovementEnum movement, Vector3 smoothPosDir, Vector3 smoothNegDir, float movementLoop, ref float transparency) { switch (movement) { case HandMovementEnum.Static: default: float staticLoopMulitiplier = StaticCurve.Evaluate(movementLoop); animator.SetFloat(ForwardParam, smoothPosDir.z * staticLoopMulitiplier * MovementScale); animator.SetFloat(BackParam, smoothNegDir.z * staticLoopMulitiplier * MovementScale); animator.SetFloat(LeftParam, smoothPosDir.x * staticLoopMulitiplier * MovementScale); animator.SetFloat(RightParam, smoothNegDir.x * staticLoopMulitiplier * MovementScale); animator.SetFloat(UpParam, smoothPosDir.y * staticLoopMulitiplier * MovementScale); animator.SetFloat(DownParam, smoothNegDir.y * staticLoopMulitiplier * MovementScale); break; case HandMovementEnum.PingPong: float pingPongMultiplier = PingPongCurve.Evaluate(movementLoop); animator.SetFloat(ForwardParam, smoothPosDir.z * pingPongMultiplier * MovementScale); animator.SetFloat(BackParam, smoothNegDir.z * pingPongMultiplier * MovementScale); animator.SetFloat(LeftParam, smoothPosDir.x * pingPongMultiplier * MovementScale); animator.SetFloat(RightParam, smoothNegDir.x * pingPongMultiplier * MovementScale); animator.SetFloat(UpParam, smoothPosDir.y * pingPongMultiplier * MovementScale); animator.SetFloat(DownParam, smoothNegDir.y * pingPongMultiplier * MovementScale); break; case HandMovementEnum.Directional: float directionalMultiplier = DirectionalCurve.Evaluate(movementLoop); animator.SetFloat(ForwardParam, smoothPosDir.z * directionalMultiplier * MovementScale); animator.SetFloat(BackParam, smoothNegDir.z * directionalMultiplier * MovementScale); animator.SetFloat(LeftParam, smoothPosDir.x * directionalMultiplier * MovementScale); animator.SetFloat(RightParam, smoothNegDir.x * directionalMultiplier * MovementScale); animator.SetFloat(UpParam, smoothPosDir.y * directionalMultiplier * MovementScale); animator.SetFloat(DownParam, smoothNegDir.y * directionalMultiplier * MovementScale); if (direction != HandDirectionEnum.None) { transparency *= DirectionalTransparencyCurve.Evaluate(movementLoop); } break; /*case HandMovementEnum.Random: * break;*/ } }
private bool GetLoopedTime(ref float normalizedLoop, ref float normalizedLoopLastFrame, ref float movementLoop, float movementChangeTime, HandMovementEnum handMovement) { normalizedLoop = Mathf.Clamp01(Mathf.Repeat(Time.time - movementChangeTime, MovementLoopTime) / MovementLoopTime); switch (handMovement) { case HandMovementEnum.Directional: float directionalLoop = Mathf.Repeat(Time.time - movementChangeTime, MovementLoopTime) / MovementLoopTime; movementLoop = Mathf.Lerp(movementLoop, directionalLoop, Mathf.Clamp01(Time.time - movementChangeTime)); break; case HandMovementEnum.PingPong: float pingPongLoop = Mathf.PingPong(Time.time - movementChangeTime, MovementLoopTime) / MovementLoopTime; movementLoop = Mathf.Lerp(movementLoop, pingPongLoop, Mathf.Clamp01(Time.time - movementChangeTime)); break; case HandMovementEnum.Static: float staticLoop = Mathf.Clamp(Time.time - movementChangeTime, 0f, MovementLoopTime) / MovementLoopTime; movementLoop = Mathf.Lerp(movementLoop, staticLoop, Mathf.Clamp01(Time.time - movementChangeTime)); break; } bool looped = normalizedLoop < normalizedLoopLastFrame; normalizedLoopLastFrame = normalizedLoop; return(looped); }