[박치영] 전투 및 충돌시스템 작업
parent
bb659ad091
commit
31271a62b0
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -67,11 +67,6 @@ ACombatCharacter::ACombatCharacter()
|
||||||
Health = 100.f;
|
Health = 100.f;
|
||||||
|
|
||||||
PelvisBoneName = TEXT("pelvis");
|
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()
|
void ACombatCharacter::BeginPlay()
|
||||||
|
@ -107,14 +102,15 @@ float ACombatCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent
|
||||||
|
|
||||||
CharacterTakeDamage(fDamage);
|
CharacterTakeDamage(fDamage);
|
||||||
|
|
||||||
//TODO : Sound, Effect Emitter, Play anim montage
|
//Play Sound
|
||||||
//static void PlaySoundAtLocation(
|
UGameplayStatics::PlaySoundAtLocation(this, HitSound, PointDamageEvent->HitInfo.Location);
|
||||||
// const UObject * WorldContextObject, USoundBase * Sound, FVector Location,
|
|
||||||
// float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f,
|
//Hit Effect
|
||||||
// class USoundAttenuation* AttenuationSettings = nullptr, USoundConcurrency * ConcurrencySettings = nullptr,
|
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), HitEmitter, PointDamageEvent->HitInfo.Location);
|
||||||
// const UInitialActiveSoundParams * InitialParams = nullptr)
|
|
||||||
//UGameplayStatics::PlaySoundAtLocation(this, HitSound, PointDamageEvent->HitInfo.Location);
|
//Play Animation
|
||||||
PlayAnimMontage(HitMontage);
|
PlayAnimMontage(HitMontage);
|
||||||
|
|
||||||
IsDisabled = true;
|
IsDisabled = true;
|
||||||
}
|
}
|
||||||
return fDamage;
|
return fDamage;
|
||||||
|
@ -308,13 +304,13 @@ void ACombatCharacter::ApplyHitReactionPhysicsVelocity(float InitialSpeed)
|
||||||
|
|
||||||
void ACombatCharacter::EnableRagdoll()
|
void ACombatCharacter::EnableRagdoll()
|
||||||
{
|
{
|
||||||
GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_None, 0);
|
GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_None, 0); //movement 더 이상 없게 바꿈
|
||||||
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore);
|
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore); //충돌무시
|
||||||
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);
|
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore); //카메라 충돌무시
|
||||||
FAttachmentTransformRules rules(EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, true);
|
FAttachmentTransformRules rules(EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, true);
|
||||||
GetCameraBoom()->AttachToComponent(GetMesh(), rules, PelvisBoneName);
|
GetCameraBoom()->AttachToComponent(GetMesh(), rules, PelvisBoneName); //camera를 척추뼈에 붙임
|
||||||
GetCameraBoom()->bDoCollisionTest = false;
|
GetCameraBoom()->bDoCollisionTest = false; //카메라 충돌 없게 함
|
||||||
GetMesh()->SetCollisionProfileName(TEXT("ragdoll"), true);
|
GetMesh()->SetCollisionProfileName(TEXT("ragdoll"), true); //ragdoll 로 변경
|
||||||
GetMesh()->SetAllBodiesBelowSimulatePhysics(PelvisBoneName, true, true);
|
GetMesh()->SetAllBodiesBelowSimulatePhysics(PelvisBoneName, true, true);
|
||||||
GetMesh()->SetAllBodiesBelowPhysicsBlendWeight(PelvisBoneName, 1.f);
|
GetMesh()->SetAllBodiesBelowPhysicsBlendWeight(PelvisBoneName, 1.f);
|
||||||
}
|
}
|
||||||
|
@ -370,10 +366,10 @@ void ACombatCharacter::PerformDeath()
|
||||||
{
|
{
|
||||||
IsDead = true;
|
IsDead = true;
|
||||||
EnableRagdoll();
|
EnableRagdoll();
|
||||||
ApplyHitReactionPhysicsVelocity(2000.f);
|
ApplyHitReactionPhysicsVelocity(2000.f); //충돌을 좀 더 그럴싸하게 하기 위해서 뒷방향으로 충격
|
||||||
|
|
||||||
if (IsValid(CombatComponent->GetMainWeapon()))
|
if (IsValid(CombatComponent->GetMainWeapon()))
|
||||||
CombatComponent->GetMainWeapon()->SimulateWeaponPhysics();
|
CombatComponent->GetMainWeapon()->SimulateWeaponPhysics(); //무기의 충돌킴
|
||||||
|
|
||||||
FTimerHandle deathTimer;
|
FTimerHandle deathTimer;
|
||||||
GetWorld()->GetTimerManager().SetTimer(deathTimer, FTimerDelegate::CreateLambda([&]()
|
GetWorld()->GetTimerManager().SetTimer(deathTimer, FTimerDelegate::CreateLambda([&]()
|
||||||
|
@ -381,7 +377,7 @@ void ACombatCharacter::PerformDeath()
|
||||||
if (IsValid(CombatComponent->GetMainWeapon()))
|
if (IsValid(CombatComponent->GetMainWeapon()))
|
||||||
CombatComponent->GetMainWeapon()->Destroy();
|
CombatComponent->GetMainWeapon()->Destroy();
|
||||||
this->Destroy();
|
this->Destroy();
|
||||||
}), 4.f, false);
|
}), 4.f, false); // 4초 후에 object 삭제
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ACombatCharacter::CanPerformToggleCombat()
|
bool ACombatCharacter::CanPerformToggleCombat()
|
||||||
|
|
|
@ -102,6 +102,7 @@ private:
|
||||||
|
|
||||||
void PerformAttack(int32 attackIndex);
|
void PerformAttack(int32 attackIndex);
|
||||||
void PerformDodge();
|
void PerformDodge();
|
||||||
|
UFUNCTION(BlueprintCallable) //ŔÓ˝Ă
|
||||||
void PerformDeath();
|
void PerformDeath();
|
||||||
|
|
||||||
bool CanPerformToggleCombat();
|
bool CanPerformToggleCombat();
|
||||||
|
@ -115,19 +116,26 @@ public:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Weapon", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Weapon", meta = (AllowPrivateAccess = "true"))
|
||||||
TSubclassOf<class ABaseEquippable> Weapon;
|
TSubclassOf<class ABaseEquippable> Weapon;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
||||||
FName PelvisBoneName;
|
FName PelvisBoneName;
|
||||||
|
|
||||||
private:
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
||||||
//TODO : particle, sound 추가
|
|
||||||
//class USoundWave* HitSound;
|
|
||||||
TObjectPtr<UAnimMontage> HitMontage;
|
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:
|
private:
|
||||||
bool CombatEnabled;
|
bool CombatEnabled;
|
||||||
bool IsTogglingCombat;
|
bool IsTogglingCombat;
|
||||||
bool IsDodge;
|
bool IsDodge;
|
||||||
bool IsDisabled;
|
bool IsDisabled;
|
||||||
bool IsDead;
|
bool IsDead;
|
||||||
float Health;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,6 @@ void UCollisionComponent::TickComponent(float DeltaTime, ELevelTick TickType, FA
|
||||||
|
|
||||||
void UCollisionComponent::CollisionTrace()
|
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;
|
FVector StartLocation, EndLocation;
|
||||||
StartLocation = CollisionMeshComponent->GetSocketLocation(StartSocketName);
|
StartLocation = CollisionMeshComponent->GetSocketLocation(StartSocketName);
|
||||||
EndLocation = CollisionMeshComponent->GetSocketLocation(EndSocketName);
|
EndLocation = CollisionMeshComponent->GetSocketLocation(EndSocketName);
|
||||||
|
|
Loading…
Reference in New Issue