Unrecognized type 'static'

Trying to increment and decrement a variable from another .cpp file, and it gave me an error about nonstatic variable members, so i changed it to static and now i’m getting this error.

Declaration Of Variable:

UPROPERTY(EditAnywhere, BluePrintReadWrite, Category = Key)
		static int32 Keys;

In my .cpp

Keys = 0;

void AKeyItem::OnOverlap(class AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 HitResult, bool Impulse, const FHitResult& Overlap)
{
	ADungeonExplorerCharacter::Keys += 1;
	Destroy(false, true);
}

Seems like reflection code generator doesn’t support it.

Instead of static usage try to get pointer to you character and use

MyCharacter->Keys += 1;

instead

How would i go about doing this? Sorry i know my pointers it’s just i’m having a mental block at the moment ~_~

Because

ADungeonExplorerCharacter *MyCharacter;

Throws me the error:

error C4700: uninitialized local variable 'MyCharacter' used

Pool on arguments of overlap, it gives you actor that triggered the event (Other), you just need to check if its your character with IsA function, cast and call from other

Also i dont see point of using static, if youwant something more global use classes like gamemode or gamestate

As mentioned above if you want some global parameter you’d better use variable in GameMode or even create your game singleton class if you want even more global thing independent from game modes.
You can always get those variables then using Kismet:

UMyGameMode* MyGM = Cast<UMyGameMode>(UGameplayStatics::GetGameMode(this));
MyGM->Keys++;

or using singleton:

UMyGameSingleton::Get().Keys++;

That MyCharacter in my example was just a random variable name which points to your character. You can get it by different ways: you can define public variable of type ADungeonExplorerCharacter* in your class that uses Keys and set it from your PC or GameMode or you can set a global variable in GameMode or singleton class (and get it by using method above).

My main issue is accessing The character classes variables, i understand what you are saying.

What happens if you remove the UPROPERTY from the variable? I don’t think blueprints like static member variables much.

Same problem

UPROPERTY(EditAnywhere, BluePrintReadWrite, Category = “”)

// This should be

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "")