void UBTService_ForcusTarget::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
auto Controller = Cast<APSAIController>(OwnerComp.GetAIOwner());
APSCharacter* Character = Cast<APSCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
Controller->GetBlackboard()->SetValueAsVector(APSAIController::TargetLocationKey, Character->GetActorLocation());
Controller->GetBlackboard()->SetValueAsObject(APSAIController::TargetKey, Character);
auto PSEnemy = Cast<APSEnemy>(OwnerComp.GetAIOwner()->GetPawn());
auto Target = Cast<APSCharacter>(OwnerComp.GetBlackboardComponent()->GetValueAsObject(APSAIController::TargetKey));
FVector LookVector = Target->GetActorLocation() - PSEnemy->GetActorLocation();
LookVector.Z = 0.0f;
FRotator TargetRot = FRotationMatrix::MakeFromX(LookVector).Rotator();
PSEnemy->SetActorRotation(TargetRot);
}
์ด๊ฒ ์ ๋ถ์
์ด๋ ๊ฒํ๋ฉด ai๋ ํญ์ ์ ์ ๋ฅผ ๋ฐ๋ผ๋ด. ๊ณ์ ์์ ์ ๋ฐ๋ผ์ด
๊ทผ๋ฐ ์ด๋ํ ๋ ์ฝ๊ฐ ๋ญ๋ผํด์ผํ ๊น ํฌ์ธํธ ์ฐ๊ณ ์ด๋ํ๋ค๊ณ ํด์ผ๋๋ ์ด๋ํ๋ค๊ฐ ํ๋ ์ด์ด๊ฐ ๋ฐฉํฅ ํ๋ฉด ์ ๊น ๋ฉ์นซํ๊ณ ๋ฐ๋ผ๊ฐ๊ณ ์กฐ๊ธ ๊ฐ๋ชฉ์ฒ๋ผ ์์ง์
์์์ฒจ๋ถ์๋๋ ์๊ฐ๋๋ผ ์์ฝ๋ค ใ
ํจ
๋ด ์๊ฐ๋๋ก๋ผ๋ฉด ์ ๊ธฐ์ TickNode๋๊น ํฑ๋ง๋ค ์ด์จ๋ TargetLocation ๋ธ๋๋ณด๋์ ์ ์ ์ ์์น๊ฐ ๋ค์ด๊ฐ์ผ๋์ง์๋ ์ถ์๋ฐ moveto๊ฐ ํฑ๋ง๋ค ํธ์ถ์ด ์๋์ด์ ๊ทธ๋ฐ๊ฑด๊ฐ?
MoveTo์ ๋ธ๋๋ณด๋ ๊ฐ ๊ด์ฐฐ ์ผฐ๋์ง๋ ์๋น์ค ์ธํฐ๋ฒ ๋ช์ผ๋ก ๋์ด์๋์ง ํ์ธํด๋ณด์ - dc App
์ฅ ๋ธ๋๋ณด๋๊ฐ ๊ด์ฐฐ์ด ๋ญ์ง ๋ชฐ๋ผ์ ์ํค๊ณ ์์์.
์ ์ธํฐ๋ฒ์ ์ค์ท ์ฐ์ด๋จ๊ตฌ๋จผ - dc App
๊ทธ๊ฑฐ ์ผ์ผ ๊ฐฑ์ ๋ ๋๋ง๋ค ๋ชฉ์ ์ง ๋ฐ๋ - dc App
์ ๋ฏธ์น ๋๋ค
๊ฐ์ฌํฉ๋๋ค. ์๋ ์ ์ด๋ฐ๊ฒ ์๋์ค ๋ชฐ๋์ ใ ใ ์ด์ฉ์ง ์์ ๋ฐ๋ผ๊ฐ๋๊ฒ tick๋ง๋ค ๋๋ฉด ๋ถ๋ช ํ ์ ์ ์์น๋ tick๋ง๋ค ๋ด๊ธด๋ค๋ ๋ป์ธ๋ฐ ์ ์๋๋ํ์ ๊ฐ์ฌํฉ๋๋ค