Maybe its obvious but for me this is not working.
.h File:
UCLASS()
class ASolidBlock : public AActor
{
GENERATED_UCLASS_BODY()
virtual void BeginPlay() OVERRIDE;
// static mesh
TSubobjectPtr<UStaticMeshComponent> Block;
};
.cpp file:
ASolidBlock::ASolidBlock(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
Block = PCIP.CreateAbstractDefaultSubobject(this, TEXT("Block"));
//static ConstructorHelpers::FObjectFinder <UStaticMeshComponent> StaticMesh("StaticMesh'/Game/SolidBlock.uasset'");
//Block->SetStaticMesh(StaticMesh.Object);
}
void ASolidBlock::BeginPlay()
{
GEngine->AddOnScreenDebugMessage(-1, 4, FColor::Blue, TEXT("SOLIDBLOCK BEGINPLAY"));
}
This leads to a compile error. The Line:
Block = PCIP.CreateAbstractDefaultSubobject(this, TEXT("Block"));
give the error:
error C2783: ‘TSubobjectPtrConstructor FPostConstructInitializeProperties::CreateAbstractDefaultSubobject(UObject *,FName,bool) const’ : could not deduce template argument for ‘TReturnType’
i also read in
about someone who wants to spawn meshes and has problems. would be great you could help Maybe its too obvious and i dont see it