Blueprint not listed in property dropdowns

Hi guys, I have created a UWeapon which inherits UObject.
Here is the header:

UENUM(BlueprintType)
namespace EWeaponType
{
	enum Type
	{
		Pistol,
		Rifle,
		Sniper,
		Shotgun,
		GranadeLauncher
	};
}

UCLASS(Blueprintable)
class TESTINGGROUND_API UWeapon : public UObject
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Weapon")
	TEnumAsByte<EWeaponType::Type> WeaponType;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ammo")
	int32 AmmoCapacity;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ammo")
	int32 ClipCapacity;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ammo")
	int32 RemainingAmmo;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ammo")
	int32 AmmoInClip;

	/** Projectile class to spawn */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Projectile")
	TSubclassOf<AProjectileBase> ProjectileClass;

	UFUNCTION(BlueprintCallable, Category = "Weapon")
	void Reload();

	UFUNCTION(BlueprintCallable, Category = "Weapon")
	int32 AddAmmo(int32 Ammo);
};

And the source file:

UWeapon::UWeapon(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

}

void UWeapon::Reload()
{
	if ((this->AmmoInClip < this->ClipCapacity) && (this->RemainingAmmo > 0))
	{
		int32 AmmoToReload = this->ClipCapacity - this->AmmoInClip;

		if (this->RemainingAmmo > AmmoToReload)
		{
			this->AmmoInClip += AmmoToReload;
			this->RemainingAmmo -= AmmoToReload;
		}
		else
		{
			this->AmmoInClip += this->RemainingAmmo;
			this->RemainingAmmo = 0;
		}
	}
}

int32 UWeapon::AddAmmo(int32 Ammo)
{
	int32 AddedAmount = Ammo;

	this->RemainingAmmo += Ammo;
	if (this->RemainingAmmo > this->AmmoCapacity)
	{
		AddedAmount = Ammo - (this->RemainingAmmo - this->AmmoCapacity);
		this->RemainingAmmo = this->AmmoCapacity;
	}

	return AddedAmount;
}

In my character class I have a pointer to a UWeapon defined and initialized in the constructor like this:

// Definition
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Weapon")
TWeakObjectPtr<UWeapon> Rifle;

// Initialize default rifle in the Character's constructor
this->Rifle = NewObject<UWeapon>();

I have also created a Blueprint which inherits UWeapon in order to set the Rifle property of my character. The problem is that the Blueprint is not listed in the dropdown. Can anyone tell why is that?

Here are the pics:

Thanks mate, I am going to try it out, and tell you if it works, but I am not sure if I can spawn a basic UObject.

I want to use the values from the blueprint in my C++ code, but I can’t set the Rifle pointer to point to an instance of a Blueprint class.

Try having TSubclassOf Rifleclass; Im assuming if you want to change the weapon you are using youd have to do it this way, perhaps because your pointer needs to point to an existing instance of a class instead of declarations of other classes with the same inheritance. Then when you spawn, save the pointer that the spawn function gives you.

TSubclassOf RifleClass;

I thought you wanted the pointer to spawn or something, depends what you are doing with that pointer :), if you just want some information from a blueprint then no need to spawn or anything just grab values.

Hey man, you actually helped me. I have a RifleClass. And with RifleClass->GetDefaultObject() I get the default object that’s been created (The default object is actually the blueprint that I linked in the editor). Thank you very much.

Create an instance of your object using the RifleClass that you set in blueprint, then link that instance to your pointer and youll be able to use the values. link text This is to create an instance of your Uobject (instead of spawning). Use the RifleClass here and the variables will be those that you set in blueprint.

woops didnt see this, no problem.Thats a good way to do it too, mark as resolved :slight_smile: