ProvideContext is a const function, and thus cant alter member variables. You’ll probably have issues with your FoundActor too
why am I getting this error? (Expression must be a modifiable lvalue)
I cant Equal any value, every value every time I get this error.
the Code :
.h :
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "EnvironmentQuery/EnvQueryContext.h"
#include "GetPlayerContext.generated.h"
/**
*
*/
UCLASS()
class SHOOTEMUP_API UGetPlayerContext : public UEnvQueryContext
{
GENERATED_BODY()
public:
UGetPlayerContext();
virtual void ProvideContext(FEnvQueryInstance& QueryInstance, FEnvQueryContextData& ContextData) const;
APawn * FirstPlayerPawn;
AActor* FoundActor;
bool MyDoOnce = true;
};
.ccp:
#include "GetPlayerContext.h"
#include "Engine/World.h"
#include "GameFramework/Actor.h"
#include "AITypes.h"
#include "AIControllerV1.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "EnvironmentQuery/Items/EnvQueryItemType_Actor.h"
#include "EnvironmentQuery/Items/EnvQueryItemType_Point.h"
#include "EnvironmentQuery/EnvQueryManager.h"
#include "MyPawnShip.h"
UGetPlayerContext::UGetPlayerContext()
{
MyDoOnce = true;
FoundActor = UGameplayStatics::GetActorOfClass(GetWorld(), AMyPawnShip::StaticClass());
}
void UGetPlayerContext::ProvideContext(FEnvQueryInstance& QueryInstance, FEnvQueryContextData& ContextData) const
{
Super::ProvideContext(QueryInstance, ContextData);
if (MyDoOnce)
{
AAIControllerV1* AICon = Cast<AAIControllerV1>((Cast<AActor>((QueryInstance.Owner).Get())->GetInstigatorController()));
MyDoOnce = fasle;
}
if (FoundActor)
{
//Set the context SeeingPawn to the provided context data
UEnvQueryItemType_Actor::SetContextHelper(ContextData, FoundActor);
}
}
I think im blind, lol.
thanks, bro for the answer and fast replay.