Hello guys, I need some help on it, I did it a lot with blueprints, but now trying to do it in C++ I get stuck in an error.
I have an interface called ULockOnInterface, it is blueprint callable
// This class does not need to be modified.
UINTERFACE(MinimalAPI, Blueprintable)
class ULockOnInterface : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class DMETPRISONPROJECT_API ILockOnInterface
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
};
I am making this hit with Sphere, it is working
bool hit = UKismetSystemLibrary::SphereTraceMultiForObjects(GetWorld(), startPoint, startPoint, 750.0f, ObjectTypesArray, false, ActorsToIgnore, EDrawDebugTrace::ForDuration, HitArray, true, FLinearColor::Gray, FLinearColor::Blue, 30.0f);
but when I try to cast the actor to my interface in this part of the code:
for (FHitResult hitResult : HitArray)
{
AActor* hitActor = hitResult.GetActor();
ULockOnInterface* myLock = Cast<ULockOnInterface>(hitActor);
if (myLock)
{
LockOnTargets.AddUnique(*hitResult.GetActor());
Distance = 1000000.0f;
}
}
I get an error compiling:
1>D:\EPIc\Unreal 5.5\UnrealEngine\Engine\Source\Runtime\Core\Public\Containers\Array.h(1014): error C2678: ‘==’ binary : binary ‘==’ : no operator found which takes a left-hand operand of type ‘const AActor’
Someone can help me with it?
I tryed it too:
const AActor* hitActor = hitResult.GetActor();
const ULockOnInterface* myLock = Cast<const ULockOnInterface>(hitActor);
but same result.