기본 공격 알고리즘 설계중

This commit is contained in:
SJW1024
2023-10-15 00:35:56 +09:00
parent fe6d559697
commit d3025bfbfa
8 changed files with 63 additions and 15 deletions

View File

@@ -371,15 +371,63 @@ void ADefaultPlayerController::ObjectSelect()
SetACharacterOutlineColor(HitObject, true);
}
void ADefaultPlayerController::Move()
{
FVector Destination = GetMouseHitLocation();
FHitResult HitResult;
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_WorldStatic));
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Pawn));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Moving);
SimpleMoveToLocation(this, Destination);
this->MoveToLocation(Destination);
GetHitResultUnderCursorForObjects(ObjectTypes, true, HitResult);
ACharacter* HitObject = Cast<ACharacter>(HitResult.GetActor());
if (HitObject != nullptr)
{
float MinDistance = 100000.0f; // <20>ּ<EFBFBD> <20>Ÿ<EFBFBD>
FVector Destination = HitObject->GetActorLocation(); // HitObject<63><74> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if (FVector::Dist(Destination, GetPawn()->GetActorLocation()) <= MinDistance)
{
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
Server_StopMove();
Multicast_StopMove();
Multicast_SetRotation(GetMouseHitLocation());
Server_SetRotation(GetMouseHitLocation());
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Attack);
}
else
{
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Moving);
SimpleMoveToLocation(this, Destination);
this->MoveToLocation(Destination);
}
}
else
{
HitObject = nullptr;
FVector Destination = GetMouseHitLocation();
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Moving);
SimpleMoveToLocation(this, Destination);
this->MoveToLocation(Destination);
}
}
void ADefaultPlayerController::Multicast_SetRotation_Implementation(FVector MouseHitLocation)
{
FVector Location = GetPawn()->GetActorLocation();