// All content (c) Shaun Reed 2021, all rights reserved #include "ActorSpawner.h" // Include the header file from the actor we want to spawn #include "BallActor.h" // Engine includes #include "Components/BoxComponent.h" // Sets default values AActorSpawner::AActorSpawner() { RootComponent = CreateDefaultSubobject(TEXT("DefaultSceneRoot")); SpawnVolume = CreateDefaultSubobject(TEXT("SpawnVolume")); SpawnVolume->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform); } void AActorSpawner::SpawnActor() { // Get initial position and rotation, then spawn the actor FVector SpawnLocation = GetActorLocation(); FRotator SpawnRotation = GetActorRotation(); GetWorld()->SpawnActor(SpawnLocation, SpawnRotation); } // Called when the game starts or when spawned void AActorSpawner::BeginPlay() { Super::BeginPlay(); } // Called every frame void AActorSpawner::Tick(float DeltaTime) { Super::Tick(DeltaTime); }