hi everyone, a weird problem. i am trying to spawn an Actor to the scene and it works fine except the spawning part (:
i spawned two other Actors to the scene and they are Spawning accurately. let me give a better view.
i have a Floor Class which Spawns by some rules in the world. now i want to spawn some coins when i spawn floor.
so i decided to code it like this. here is some codes of the Floor.h::
UPROPERTY(EditAnywhere, Category = "Floor Blueprint")
TSubclassOf<AFloor> FloorBP = NULL;
UPROPERTY(EditAnywhere, Category = "CoinBP")
TSubclassOf<class ACoin> CoinBP = NULL;
and here is some of the key parts of Floor.cpp which when floor Spawns i want to spawn the coins.
void AFloor::OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
//PlayerPassedFloor.Broadcast();
SpawnFloorAtLocation.X = this->GetActorLocation().X;
SpawnFloorAtLocation.Y = this->GetActorLocation().Y;
SpawnFloorAtLocation.Z = this->GetActorLocation().Z;
SpawnFloorAtLocation.X += (BoxCompEndOverlap->GetComponentLocation().X - BoxCompStartOverlap->GetComponentLocation().X) + FloorDistance;
//UE_LOG(LogTemp, Error, TEXT("%f"), a)
SpawnFloorWithRotation = FRotator(0.f, 0.f, 0.f);
//Spawn new Floor at the end of other floor.
auto NewFloor = GetWorld()->SpawnActor<AFloor>(FloorBP, SpawnFloorAtLocation, SpawnFloorWithRotation);
//when ever floor get spawned, coins should be spawn too
if (CoinBP) {
if (GetWorld()) {
GetWorld()->SpawnActor<ACoin>(CoinBP, FVector(0.f, 0.f, 1000.f), SpawnFloorWithRotation);
UE_LOG(LogTemp, Error, TEXT("COIN COIN COIN"))
}
}
}
}
everything works fine even that UE_LOG below the GetWorld()->SpawnActor(CoinBP, FVector(0.f, 0.f, 1000.f), SpawnFloorWithRotation); works but why on earth nothing Spawns to the scene?
thank you x_X