구르기를 구현하였습니다.
미리 만들었던 블루프린트를 참고하여 C++로 구현했으며 공중에 있을 시 작동되던 공격과 구르기, 달리기 부분도 수정하였습니다.
void ASLPlayerCharacter::Roll()
{
if (!CheckIsJumping())
{
if (GetCharacterMovement()->Velocity.Size() > 1.0f && DoOnce)
{
DoOnce = false;
FVector MovementInputVector = GetLastMovementInputVector();
FRotator RollingRotation = MovementInputVector.Rotation();
SetActorRotation(RollingRotation);
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if (AnimInstance)
{
// Montage End Event Delegate
FOnMontageEnded MontageEndedDelegate;
MontageEndedDelegate.BindUObject(this, &ASLPlayerCharacter::OnMontageEnded);
// Montage Play
AnimInstance->Montage_Play(RollMontage);
AnimInstance->Montage_SetEndDelegate(MontageEndedDelegate);
}
}
}
}
시작은 IsJumping 중인지 확인합니다.
점프 중이 아니라면 구르기 동작으로 시행하게 되는데 이동하는 방향으로 Rotation을 설정해 구르는 만큼 움직이게 만들었습니다.
bool ASLPlayerCharacter::CheckIsJumping()
{
if (GetCharacterMovement()->IsFalling())return true;
else return false;
}
점프 판정은 간단하게 Bool 함수를 만들어 캐릭터가 공중에 떠있는 중인지 확인하게 했습니다.
결과의 return값을 공격,달리기,구르기에 넣어주었으며 차후에 추가되는 스킬이나 행동 부분에도 넣을 예정입니다.