Download

property value from UClass ?

Hi

I have my c++ USpawnPoint class (derived from UActorComponent) this class
have property field:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = “TowerDefender|SpawnPoints”)
TArray<TSubclassOf<class AUnitDefender> > UnitTemplates;

I also have my AUnitDefender (c++) derived from ACharacter with have property field:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = “TowerDefender|Defenders”)
int32 SpawnPrice;

Now I have blueprint derived from AUnitDefender that sets SpawnPrice = 100;
And I have another blueprint derived from AActor with have USpawnPoint component attached and inside that component UnitTemplates list AUnitDefender derived blueprint is referenced.

This way when I want spawn bluprints derived from AUnitDefender (with various customizations) I can easilly do this.
(just call: GetWorld()->SpawnActor<AUnitDefender>(UnitTemplates[index]))

And now my question - is my design flawed ?
With current setup I’m missing one thing, before I actually spawn bluprint derived from AUnitDefender I’m unable to know the value of SpawnPrice property of that.
Is there any way to do so ? (as this is just prototype of game I thought that it would be handy for the designer to have Unit price in the blueprint where he sets up health/speed/damage etc.)

Ops … I’v just realized that UClass->GetDefaultObject() gives me default instance of BP that I may query for values in question :]