Unrecognized type 'virtual'. How to fix?

virtual void BeginPlay() override;
with this definition in the header of a C++ file, i get the compile error ‘Unrecognized type ‘virtual’ - type must be a UCLASS, USTRUCT or UENUM’

anyone got any idea what this means? or how to fix it?

We need more code to check if you missed something. Please show us at least 5 +/- lines of code around the actual issue.

Hey Tommy,

The best would be to provide the whole .h file or ar least:

  1. The includes (No .generated.h? False Order of includes…)
  2. The class Definition (Class deriving from Class which derives from UObject)
  3. and the methods before and after BeginPlay (Maybe you forgot a semicolon?)

Greetings

Never say to someone to post a whole file. Cause he will probably just post a hundred lines header haha :smiley:

Haha see :D…

Line 29 your wrote

UPROPERTY(BlueprintReadWrite,Category = “Moba|Basic Attack|Internal”)

without declaring any property. That’s your error

Ok :smiley:

I didn’t think that through xD

Am facing the similar error with the following code, ( sorry am new to coding and UE4 )
can someone please help me out with this:

UCLASS(Blueprintable)
class TWINSTICKSHOOTER_API ABaseCharacter : public ACharacter
{
GENERATED_BODY()
public:
// health property
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = “Base Character”)
float Health = 100;

// isDead property
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Base Character")
	bool isDead = false;

// calculate death function ( helper)
      virtual void calculateDead();

// calculate health function
UPROPERTY(BlueprintCallable, Category = "Base Character")
	virtual void CalculateHealth(float delta);

#if WITH_EDITOR
// editor-centric code for changing the properies
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override;
#endif

public:
// Sets default values for this character’s properties
ABaseCharacter();

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

public:
// Called every frame
virtual void Tick(float DeltaTime) override;

// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

};