카메라에서 스크린 중앙 방향으로 발사
1. Camera Componet 이용한 방법
auto Location = m_Camera->GetComponentLocation();
auto Rot = m_Camera->GetComponentRotation();
DrawDebugLine(GetWorld(),
Location,
Location + (Rot.Vector() * AttackLength),
FColor::Red, false, 2, 0, 2);
2. APlayerCameraManager 이용한 방법
APlayerCameraManager *camManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager;
FVector camLocation = camManager->GetCameraLocation();
FVector camForward = camManager->GetCameraRotation().Vector();
DrawDebugLine(World,
camLocation,
camLocation + (camForward * AttackLength), FColor::Red, false, 2, 0, 2);
3. 디버깅
4. OnHIt 이펙트 추가
FHitResult HitResult;
FCollisionQueryParams Params(NAME_None, false, this);
bool bResult = GetWorld()->LineTraceSingleByChannel(
HitResult,
m_Camera->GetComponentLocation(),
m_Camera->GetComponentLocation() + (m_Camera->GetComponentRotation().Vector() * AttackLength),
ECollisionChannel::ECC_Visibility);
if (bResult == true)
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(),
CurrentWeapon->HitEffect,
HitResult.ImpactPoint);
}
'Unreal > Game 2 ' 카테고리의 다른 글
9.1 StatComponent (0) | 2019.06.30 |
---|---|
9. GameInstace 및 DataTable (0) | 2019.06.27 |
8.2 Aim CrossHair (0) | 2019.06.24 |
8.1 AimOffSet 적용 (0) | 2019.06.24 |
8. AimOffSet 방법 2가지 (0) | 2019.06.24 |