Unrecognized type 'TMap'

Hi guys I’ve created a simple Weapon class:

class TESTINGGROUND_API FWeapon
{
	FWeapon(EWeaponType::Type WeaponType, int32 AmmoCapacity, int32 ClipCapacity, TSubclassOf<AProjectileBase> ProjectileClass);
	~FWeapon();

	EWeaponType::Type GetWeaponType() const;

	int32 GetAmmoCapacity() const;
	void SetAmmoCapacity(int32 AmmoCapacity);

	int32 GetClipCapacity() const;
	void SetClipCapacity(int32 ClipCapacity);

	int32 GetRemainingAmmo() const;
	void SetRemainingAmmo(int32 RemainingAmmo);

	int32 GetAmmoInClip() const;
	void SetAmmoInClip(int32 AmmoInClip);

	TSubclassOf<AProjectileBase> GetProjectileClass() const;
	void SetProjectileClass(TSubclassOf<AProjectileBase> ProjectileClass);

	void Reload();

private:
	/** Weapon type */
	EWeaponType::Type WeaponType;

	/** The total ammo capacity */
	int32 AmmoCapacity;

	/** The clip capacity */
	int32 ClipCapacity;

	/** The remaining ammo (the ammo in the clip in not included) */
	int32 RemainingAmmo;

	/** The ammo loaded in the clip of the weapon */
	int32 AmmoInClip;

	/** A projectile class */
	TSubclassOf<AProjectileBase> ProjectileClass;
};

Here is the EWeaponType enumeration:

namespace EWeaponType
{
	enum Type
	{
		Pistol,
		Rifle,
		Sniper,
		Shotgun,
		GranadeLauncher
	};
}

In my character which extends ACharacter I have this property:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gun")
TMap<EWeaponType::Type, FWeapon> Weapons;

When I compile I get that error. Why is that?

Yes, it worked. Thanks a lot. I don’t want to use TArray, becuase I want to take them by key, not by index :slight_smile:

Reflection system does not support TMaps (yet? most likely because blueprint overall does not support them), so you need to remove UPROPERTY (making this varable C++ only) or use TArray insted

TMap is not exposed to reflection system.

You need to TArray<> if you want to have it exposed as UPROPERTY().