diff --git a/Assets/Scripts/Games/AirRally/Shuttlecock.cs b/Assets/Scripts/Games/AirRally/Shuttlecock.cs index 1c6814594..f1d4e6277 100644 --- a/Assets/Scripts/Games/AirRally/Shuttlecock.cs +++ b/Assets/Scripts/Games/AirRally/Shuttlecock.cs @@ -38,14 +38,15 @@ namespace HeavenStudio.Games.Scripts_AirRally void Update() { var cond = Conductor.instance; - - Vector3 lastPos = transform.position; + float startRotation; + float endrotation; + + Vector3 startPos = isReturning ? PlayerTarget.position : OtherTarget.position; + Vector3 endPos = isReturning ? OtherTarget.position : PlayerTarget.position; + Vector3 midPos; if (!GetComponent().simulated) { - float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats); - - Vector3 startPos = isReturning ? PlayerTarget.position : OtherTarget.position; - Vector3 endPos = isReturning ? OtherTarget.position : PlayerTarget.position; + flyPos = cond.GetPositionFromBeat(startBeat, flyBeats); transform.position = Vector3.LerpUnclamped(startPos, endPos, flyPos); @@ -54,11 +55,23 @@ namespace HeavenStudio.Games.Scripts_AirRally transform.position += Vector3.up * yWeight * (flyType ? TargetHeightLong : TargetHeight); } - Vector3 direction = (transform.position - lastPos).normalized; - float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; - this.transform.eulerAngles = new Vector3(0, 0, rotation - 90f); + // calculates next position + { + midPos = Vector3.LerpUnclamped(startPos, endPos, 0.5f); - if (miss && flyPos > 2f) + float yMulN = (0.5f) * 2f - 1f; + float yWeightN = -(yMulN*yMulN) + 1f; + midPos += Vector3.up * yWeightN * (flyType ? TargetHeightLong : TargetHeight); + + Vector3 direction = (midPos - startPos).normalized; + startRotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; + direction = (endPos - midPos).normalized; + endrotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; + + this.transform.eulerAngles = new Vector3(0, 0, Mathf.LerpAngle(startRotation, endrotation, flyPos) - 90f); + } + + if (miss && flyPos > 4f) { if (cond.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f) {