UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"script for creating a starfield"
// Create a Starfield void AStarfield::CreateStarfield() { for (int32 i = 0; i < NumStars; i ) { FVector Location = FMath::VRand() * StarfieldRadius; float Size = FMath::FRandRange(MinStarSize, MaxStarSize); FVector Velocity = -Location.GetSafeNormal() * StarSpeed; AStar* Star = GetWorld()->SpawnActor<AStar>(StarBlueprint); Star->SetActorLocation(Location); Star->SetActorScale3D(FVector(Size)); Star->Velocity = Velocity; } }