Check if an actor was placed in editor, or spawned at runtime?

Hello, how can I tell if an actor was placed using the editor (a coin in the world), or spawned at runtime (from a killed enemy) from within the BeginPlay function?

I need this so the coin can set up it’s parameters, such as to persist as a world coin, or to bounce around and face out.

Thanks!

If it was spawned in editor then the coin is visible with out hitting the play button. If it shows the moment you run the game then it was spawned by a blueprint (like the event begin play, you an event that was caused by your enemy dying, etc.)

I meant programmatically, how can the Coin class know if it was placed or spawned, so it can set it’s values properly.

Found a solution to my problem.

FTransform spawnTrans = FTransform(flinchDir.Rotation(), GetActorLocation());
APickup* pickup = GetWorld()->SpawnActorDeferred<APickup>(SpawnItem, spawnTrans);
pickup->ID = DropItem.ID;
pickup->WasSpawned = true;
pickup->FinishSpawning(spawnTrans);

Lets you initialize variables on an actor before actually spawning it. This way you can set certain variables, before it runs it’s BeginPlay.

All Actors have a variable called “bNetStartup” with the description “If true, this actor was loaded directly from the map, and for networking purposes can be addressed by its full path name”.

I have been able to check if an actor was placed in the map or spawned by using this flag.

It is useful for if you play a sound on spawn in PostInitializeComponents() for instance and do not want to play the sound if the actor started spawned in the world.

2 Likes

I could not find the variable you mentioned. Maybe it is not in 4.19 or above any longer?

Actor.h line 150 in 4.22.1

UPROPERTY()
bNetStartup:1;