Unreal 본격 TIL

Unreal 팀프로젝트 레벨파트 핵심 시스템

ggojun 2026. 4. 22. 22:08

 

 

>> 추나 바이킹 처럼 좌우로 기우뚱하며 왕복하는 함정 <<

void APRShovelTrap::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

    RunningTime += DeltaTime;
    float Alpha = FMath::Sin(RunningTime * SwingSpeed); 
    float CurrentAngle = Alpha * RotationLimit;
    FRotator NewRotation = FRotator(0.f, 0.f, CurrentAngle);
    SetActorRelativeRotation(NewRotation); 
}
ㄴ FMath::Sin 함수를 이용해서 부드럽고 자연스럽게 왕복하도록 함. 
회전축을 FRotator(0.f, 0.f, CurrentAngle)로 하면, Roll 방향으로 왕복함. 
이로써 추, 바이킹 같은 동선을 가진 함정이 완성. 


>> 기울어지며 경사도에 따라 플레이어가 미끄러지는 발판, 떨어지지않기 위해 중심을 잡아야하는 기믹 << 

FRotator APRSlidingPlatform::MakeRotationFromElapsedTime(float InElapsedTime) const
{
    const float CurrentPitch = FMath::Sin(InElapsedTime) * MaxTiltAngle;
    const float CurrentRoll  = FMath::Cos(InElapsedTime * 0.7f) * MaxTiltAngle;
    return FRotator(CurrentPitch, 0.f, CurrentRoll);
}
ㄴ Sin Cos 함수를 사용함. 
Sin함수로 시간에 따라 Pitch(상하 기울기)가 -MaxTiltAngle과 +MaxTiltAngle 사이를 부드럽게 왕복하게 함, 
Cos함수로 Roll(좌우 기울기)가 Pitch보다 0.7배 느린속도로 움직이게 계수를 주어, 
단조롭지 않고 비대칭적으로 움직이게 함. 
캐릭터 무브먼트 컴포넌트 부분도 특정 각도를 넘어서면 미끄러지도록 추가 수정하여 
캐릭터가 발판 위에서 떨어지지않기 위해 중심을 잡아야하는 기믹 완성. 

 

 

>> Meshy로 생성한 3D모델, 애니메이션 사용, 펫/함정(몬스터)에 적용 <<