[박치영] 전투 및 충돌시스템 작업

main
PCYPC\pcy35 2023-08-03 15:59:38 +09:00
parent bb659ad091
commit 31271a62b0
6 changed files with 30 additions and 32 deletions

View File

@ -67,11 +67,6 @@ ACombatCharacter::ACombatCharacter()
Health = 100.f;
PelvisBoneName = TEXT("pelvis");
//³ªÁß¿¡ ¼öÁ¤ÇÒ ¼ö ÀÖÀ½
static ConstructorHelpers::FObjectFinder<UAnimMontage> findHitMontage(TEXT("/Script/Engine.AnimMontage'/Game/CombatSystem/CourseFiles/Animations/HitReactions/Standing_React_Large_Front_Montage.Standing_React_Large_Front_Montage'"));
if (findHitMontage.Succeeded())
HitMontage = findHitMontage.Object;
}
void ACombatCharacter::BeginPlay()
@ -107,14 +102,15 @@ float ACombatCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent
CharacterTakeDamage(fDamage);
//TODO : Sound, Effect Emitter, Play anim montage
//static void PlaySoundAtLocation(
// const UObject * WorldContextObject, USoundBase * Sound, FVector Location,
// float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f,
// class USoundAttenuation* AttenuationSettings = nullptr, USoundConcurrency * ConcurrencySettings = nullptr,
// const UInitialActiveSoundParams * InitialParams = nullptr)
//UGameplayStatics::PlaySoundAtLocation(this, HitSound, PointDamageEvent->HitInfo.Location);
//Play Sound
UGameplayStatics::PlaySoundAtLocation(this, HitSound, PointDamageEvent->HitInfo.Location);
//Hit Effect
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), HitEmitter, PointDamageEvent->HitInfo.Location);
//Play Animation
PlayAnimMontage(HitMontage);
IsDisabled = true;
}
return fDamage;
@ -308,13 +304,13 @@ void ACombatCharacter::ApplyHitReactionPhysicsVelocity(float InitialSpeed)
void ACombatCharacter::EnableRagdoll()
{
GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_None, 0);
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore);
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);
GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_None, 0); //movement 더 이상 없게 바꿈
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore); //충돌무시
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore); //카메라 충돌무시
FAttachmentTransformRules rules(EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, true);
GetCameraBoom()->AttachToComponent(GetMesh(), rules, PelvisBoneName);
GetCameraBoom()->bDoCollisionTest = false;
GetMesh()->SetCollisionProfileName(TEXT("ragdoll"), true);
GetCameraBoom()->AttachToComponent(GetMesh(), rules, PelvisBoneName); //camera를 척추뼈에 붙임
GetCameraBoom()->bDoCollisionTest = false; //카메라 충돌 없게 함
GetMesh()->SetCollisionProfileName(TEXT("ragdoll"), true); //ragdoll 로 변경
GetMesh()->SetAllBodiesBelowSimulatePhysics(PelvisBoneName, true, true);
GetMesh()->SetAllBodiesBelowPhysicsBlendWeight(PelvisBoneName, 1.f);
}
@ -370,10 +366,10 @@ void ACombatCharacter::PerformDeath()
{
IsDead = true;
EnableRagdoll();
ApplyHitReactionPhysicsVelocity(2000.f);
ApplyHitReactionPhysicsVelocity(2000.f); //충돌을 좀 더 그럴싸하게 하기 위해서 뒷방향으로 충격
if (IsValid(CombatComponent->GetMainWeapon()))
CombatComponent->GetMainWeapon()->SimulateWeaponPhysics();
CombatComponent->GetMainWeapon()->SimulateWeaponPhysics(); //무기의 충돌킴
FTimerHandle deathTimer;
GetWorld()->GetTimerManager().SetTimer(deathTimer, FTimerDelegate::CreateLambda([&]()
@ -381,7 +377,7 @@ void ACombatCharacter::PerformDeath()
if (IsValid(CombatComponent->GetMainWeapon()))
CombatComponent->GetMainWeapon()->Destroy();
this->Destroy();
}), 4.f, false);
}), 4.f, false); // 4초 후에 object 삭제
}
bool ACombatCharacter::CanPerformToggleCombat()

View File

@ -102,6 +102,7 @@ private:
void PerformAttack(int32 attackIndex);
void PerformDodge();
UFUNCTION(BlueprintCallable) //ŔÓ˝Ă
void PerformDeath();
bool CanPerformToggleCombat();
@ -115,19 +116,26 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Weapon", meta = (AllowPrivateAccess = "true"))
TSubclassOf<class ABaseEquippable> Weapon;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
FName PelvisBoneName;
private:
//TODO : particle, sound 추가
//class USoundWave* HitSound;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
TObjectPtr<UAnimMontage> HitMontage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
TObjectPtr<class USoundBase> HitSound;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
TObjectPtr<class UParticleSystem> HitEmitter;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats", meta = (AllowPrivateAccess = "true"))
float Health;
private:
bool CombatEnabled;
bool IsTogglingCombat;
bool IsDodge;
bool IsDisabled;
bool IsDead;
float Health;
};

View File

@ -36,12 +36,6 @@ void UCollisionComponent::TickComponent(float DeltaTime, ELevelTick TickType, FA
void UCollisionComponent::CollisionTrace()
{
//static bool SphereTraceMultiForObjects(
// const UObject * WorldContextObject, const FVector Start,
// const FVector End, float Radius, const TArray<TEnumAsByte<EObjectTypeQuery> > &ObjectTypes,
// bool bTraceComplex, const TArray<AActor*>&ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType,
// TArray<FHitResult>&OutHits, bool bIgnoreSelf, FLinearColor TraceColor = FLinearColor::Red,
// FLinearColor TraceHitColor = FLinearColor::Green, float DrawTime = 5.0f);
FVector StartLocation, EndLocation;
StartLocation = CollisionMeshComponent->GetSocketLocation(StartSocketName);
EndLocation = CollisionMeshComponent->GetSocketLocation(EndSocketName);