28 float GravityZ = -980.f)
30 if (
Time <= KINDA_SMALL_NUMBER)
31 return FVector::ZeroVector;
33 const FVector g(0, 0, GravityZ);
58 FVector Base = FMath::Lerp(Start, End, Alpha);
59 float OffsetZ = FMath::Sin(Alpha * PI) * Height;
60 return Base + FVector(0, 0, OffsetZ);
88 float GravityZ = -980.f,
89 int32 NumSegments = 20,
90 float StepTime = 0.1f,
91 float LifeTime = 2.0f,
92 FColor
Color = FColor::Red)
96 const FVector g(0, 0, GravityZ);
98 FVector PrevPos = Start;
99 for (int32 i = 1; i <= NumSegments; ++i)
101 float t = StepTime * i;
105 DrawDebugLine(World, PrevPos, CurrPos,
Color,
false, LifeTime, 0, 1.5f);
132 const FVector& Start,
135 const int32 NumSegments = 20,
136 const float LifeTime = 2.0f,
137 const FColor
Color = FColor::Green)
141 FVector PrevPos = Start;
142 for (int32 i = 1; i <= NumSegments; ++i)
144 const float Alpha = (float)i / (
float)NumSegments;
145 FVector CurrPos =
InterpArcSin(Start, End, Height, Alpha);
147 DrawDebugLine(World, PrevPos, CurrPos,
Color,
false, LifeTime, 0, 1.5f);
static void DrawParabolaDebug(UWorld *World, const FVector &Start, const FVector &End, const float Height, const int32 NumSegments=20, const float LifeTime=2.0f, const FColor Color=FColor::Green)
두 점(Start → End)을 잇는 곡선을 디버그 라인으로 그립니다.
static void DrawProjectileArcDebug(UWorld *World, const FVector &Start, const FVector &V0, float GravityZ=-980.f, int32 NumSegments=20, float StepTime=0.1f, float LifeTime=2.0f, FColor Color=FColor::Red)
초기 속도 V0를 이용해 물리 기반 포물선 궤적을 디버그 라인으로 그립니다.
static FVector InterpArcSin(const FVector &Start, const FVector &End, float Height, float Alpha)
선형 보간 경로에 사인 함수를 더해 아치 형태의 곡선을 생성합니다.
static FVector SolveV0ForProjectile(const FVector &Start, const FVector &End, float Time, float GravityZ=-980.f)
주어진 시간 안에 목표 지점에 도달하기 위한 초기 속도를 계산합니다.