VansFannel VansFannel - 20 days ago 6
C++ Question

The method with the override invalidator did not invalidate any base class method

I'm learning Unreal Engine 4.13.2 and C++ using Visual Studio 2015 Enterprise.

I think my problem is a C++ so I think the best place to ask about it is here.

I have a C++ class that inherits from AActor class. I have to override a method from AActor so I have put this on my header file:

virtual void ReceiveHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit);


And also I have implemented in the cpp file.

But I get the following compiler error:


MyActor.h(23): error C3668: 'MyActor::ReceiveHit': The method with the
override invalidator did not invalidate any base class method


I have copied
ReceiveHit
method from AActor.h file and I get that error.

I have also another methods overridden without problems. This is
MyActor
header file:

#pragma once

#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class MYGAME_API AMyActor : public AActor
{
GENERATED_BODY()

public:
// Sets default values for this actor's properties
AMyActor();

// Called when the game starts or when spawned
virtual void BeginPlay() override;

// Called every frame
virtual void Tick( float DeltaSeconds ) override;

virtual void ReceiveHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;

private:
UProjectileMovementComponent* MyMovement;
};


How can I fix this error?

Answer

The problem is that this is not a virtual method. They've changed the API and I was following an old example.

No, I can use NotifyHit that is virtual and I can override it:

virtual void NotifyHit
(
    class UPrimitiveComponent * MyComp,
    AActor * Other,
    class UPrimitiveComponent * OtherComp,
    bool bSelfMoved,
    FVector HitLocation,
    FVector HitNormal,
    FVector NormalImpulse,
    const FHitResult & Hit
)