using System; using System.Collections; using UnityEngine; public class Projectile_Curved : ProjectileBase { public void Launch_Curved(Vector3 start, Vector3 end, float duration, float curveHeight, bool endoff, Action endact = null) { StartCoroutine(MoveAlongCurve(start, end, duration, curveHeight, endoff, endact)); } private IEnumerator MoveAlongCurve(Vector3 start, Vector3 end, float duration, float curveHeight, bool endoff, Action endact) { float elapsedTime = 0f; Vector3 controlPoint = (start + end) * 0.5f; // 시작과 끝의 중간 지점 controlPoint += Vector3.up * curveHeight; // 곡선 높이 추가 while (elapsedTime < duration) { elapsedTime += Time.deltaTime; float t = elapsedTime / duration; // 베지어 곡선 계산 Vector3 pointOnCurve = Mathf.Pow(1 - t, 2) * start + 2 * (1 - t) * t * controlPoint + Mathf.Pow(t, 2) * end; // 투사체 위치 이동 transform.position = pointOnCurve; yield return null; } transform.position = end; if (endoff) Off(true); endact?.Invoke(); } }