개발일지
08-22~ 08-23 보스 몬스터 기본공격 수정 및 패턴1, 중간보스 쉴드 버그 수정
ksw8596
2024. 8. 23. 09:28

소켓을 추가하여 기본공격이 손에서 범위형 공격을 할 수 있게 추가하였다.

3번공격은 양손에서 한번씩 공격하므로 Flip Flop을 사용하여 범위공격을 할 수 있게 추가하였다.


돌진할 때 Collision을 Pawn에 대해 잠깐 Overlap으로 바꿔 닿으면 Launch Character로 Player에게 데미지를 주면서 밀려나게 만들었다.

돌면서 데미지를 주는 공격이다.

돌진공격 후 한번 도는 패턴을 만들었다.
Shield.cpp
#include "Enemy/FShield.h"
#include "GameFramework/Character.h"
#include "GameFramework/PlayerController.h"
#include "Kismet/KismetSystemLibrary.h"
#include "FGameFunctionLibrary.h"
#include "Player/FAttributeComponent.h"
#include "Buff/FBuffComponent.h"
// Sets default values
AFShield::AFShield()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ShiledMesh"));
StaticMesh->OnComponentBeginOverlap.AddDynamic(this, &AFShield::OnComponentBeginOverlap);
AttributeComp = CreateDefaultSubobject<UFAttributeComponent>(TEXT("AttributeComp"));
BuffComp = CreateDefaultSubobject<UFBuffComponent>(TEXT("BuffComp"));
}
// Called when the game starts or when spawned
void AFShield::BeginPlay()
{
Super::BeginPlay();
SetLifeSpan(LifeTime);
FTimerHandle TimerHandle;
GetWorldTimerManager().SetTimer(TimerHandle, this, &AFShield::ChangeBlack, 0.2f, false);
AttributeComp->OnHealthChanged.AddDynamic(this, &AFShield::OnHealthChanged);
if (bDamageShield)
{
GetWorldTimerManager().SetTimer(TimerHandle, this, &AFShield::OnDamage, BoomTimer, false);
}
}
============================생략============================
//Actor와 Shield와 겹쳤을때 밀어주는 로직
void AFShield::OnComponentBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Blue, TEXT("Screen"));
if(OtherActor && OtherActor != this)
{
PushActor(OtherActor);
}
}
void AFShield::PushActor(AActor* ActorPush)
{
if(ActorPush)
{
ACharacter* Character = Cast<ACharacter>(ActorPush);
if(Character)
{
FVector ActorLocation = Character->GetActorLocation();
FVector ShiledLocation = GetActorLocation();
FVector Distance = (ActorLocation - ShiledLocation);
Distance.Normalize();
if (Distance.Size() < 300)
{
Character->LaunchCharacter(Distance * 3000, true, true);
}
}
}
}
void AFShield::ChangeBlack()
{
StaticMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Block);
}
- 쉴드를 Player뿐만아니라 재사용성을 위해 Actor형으로 변경하였다.