Bugfix Crash on AI with No Weapons
This commit is contained in:
parent
82de3a9342
commit
a36f65cbc6
@ -20,7 +20,11 @@ EBTNodeResult::Type UBTTask_AttackPlayer::ExecuteTask(UBehaviorTreeComponent& Ow
|
||||
{
|
||||
if (const UBlackboardComponent* const Blackboard = OwnerComp.GetBlackboardComponent())
|
||||
{
|
||||
USkeletalMeshComponent* const GunSKMesh = Cast<USkeletalMeshComponent>(AIController->GetPawn()->GetComponentsByTag(USkeletalMeshComponent::StaticClass(), "Gun")[0]);
|
||||
USkeletalMeshComponent* GunSKMesh = nullptr;
|
||||
if (AIController->GetPawn()->GetComponentsByTag(USkeletalMeshComponent::StaticClass(), "Gun").Num() > 0)
|
||||
{
|
||||
GunSKMesh = Cast<USkeletalMeshComponent>(AIController->GetPawn()->GetComponentsByTag(USkeletalMeshComponent::StaticClass(), "Gun")[0]);
|
||||
}
|
||||
FVector const Origin = IsValid(GunSKMesh) ? GunSKMesh->GetComponentLocation() : AIController->GetPawn()->GetActorLocation() + FVector(0.f, 0.f, 30.f);
|
||||
FVector const Start = Origin;
|
||||
FVector const End = Origin + AIController->GetPawn()->GetActorForwardVector() * 10000.f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user