Hey mates. Me Again.
I am unable to spawn Blueprint (or even meshes like a simple box ) for some reason. I really digged around quite a bit and I am sure that it is something that is very simple an small escaping me. So decided ask here.
- The blueprint is just the copy of the lamb blueprint in SampleContent. Just renamed it to Urgan.
- It compiles just fine. The light also turns off/on. Just there is no Blueprint spawning.
By the way I am able to use ObjectInitiailzer to create things an attach them as components and do things with them.
Here is the code:
.h
public:
void Spawningu();
UPROPERTY(EditAnywhere, Category = Spawning)
TSubclassOf<class UBlueprint> MyBlueprinten;
// I am also turning on/off a light I initilaize. No need to wonder on. It works just fine.
UFUNCTION(BluePrintCallable, Category = Properties)
void TurnOnDaLight(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
.cpp
ASaiyan::ASaiyan(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
/// there is some stuff here
static ConstructorHelpers::FObjectFinder<UBlueprint> SurpriseBlueprinten(TEXT("Blueprint'/Game/Urgan.Urgan'"));
if (SurpriseBlueprinten.Object != NULL)
{
MyBlueprinten = (UClass*)SurpriseBlueprinten.Object->GeneratedClass;
}
}
/// Turning on/off light at the same time I spawn the blueprint.
void ASaiyan::TurnOnDaLight(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
if (MeinLight != NULL )
{
MeinLight->ToggleVisibility();
Spawningu();
}
}
}
void ASaiyan::Spawningu()
{
if (MyBlueprinten != NULL)
{
UWorld* const World = GetWorld();
if (World)
{
UBlueprint* const SpawnedThing = GetWorld()->SpawnActor<UBlueprint>(MyBlueprinten, FVector(-400.0f, 0.f, 192.0f), FRotator(0.f, 0.f, 0.f), FActorSpawnParameters());
}
}
}
Thanks mates.