I want to create a custom EnvQueryGenerator_BlueprintBase, But After I finished writing the code, I found that it crashed when it was running。
This Is My .h File
#include "CoreMinimal.h"
#include "EnvironmentQuery/Generators/EnvQueryGenerator_BlueprintBase.h"
#include "MyEQG_BlueprintBase.generated.h"
/**
*
*/
UCLASS()
class GETSTARTED_API UMyEQG_BlueprintBase : public UEnvQueryGenerator_BlueprintBase
{
GENERATED_BODY()
UMyEQG_BlueprintBase();
virtual void GenerateItems(FEnvQueryInstance& QueryInstance) const override;
virtual FText GetDescriptionTitle() const override;
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
uint8 Nums = 10;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
int Gap = 50;
};
This Is My .cpp file
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyEQG_BlueprintBase.h"
#include "EnvironmentQuery/Items/EnvQueryItemType_Point.h"
UMyEQG_BlueprintBase::UMyEQG_BlueprintBase()
{
ItemType = UEnvQueryItemType_Point::StaticClass();
}
void UMyEQG_BlueprintBase::GenerateItems(FEnvQueryInstance& QueryInstance) const
{
TArray<FVector> Points;
AActor* QuerierOwner = Cast<AActor>(QueryInstance.Owner.Get());
if (!QuerierOwner) return;
FVector ActorLocation = QuerierOwner->GetActorLocation();
FVector ActorForwardVector = QuerierOwner->GetActorForwardVector();
for (uint8 i = 1; i <= Nums; i++) {
FVector Adder = ActorLocation + ActorForwardVector * i * Gap;
Points.Add(Adder);
}
if (!QuerierOwner) return;
int32 PointValueSize = GetDefault<UEnvQueryItemType_Point>()->GetValueSize();
if (Points.Num() > 0)
for (int i = 0; i < Points.Num(); i++) {
QueryInstance.AddItemData<UEnvQueryItemType_Point>(Points[i]);
}
}
FText UMyEQG_BlueprintBase::GetDescriptionTitle() const
{
return FText::FromString(TEXT("CustomNode"));
}
And It’s It asserts in
QueryInstance.AddItemData<UEnvQueryItemType_Point>(Points[i]);
The Assertion Message
Assertion failed: GetDefault<TypeItem>()->GetValueSize() <= ValueSize [File:D:\Epic Game\UE_5.3\Engine\Source\Runtime\AIModule\Classes\EnvironmentQuery\EnvQueryTypes.h] [Line: 874]