x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.13
Tags:
more ▼

asked Oct 13 '16 at 09:00 PM in C++ Programming

avatar image

Juice-Tin
156 34 35 43

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

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.

more ▼

answered Oct 14 '16 at 06:13 PM

avatar image

Juice-Tin
156 34 35 43

(comments are locked)
10|2000 characters needed characters left

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.)

more ▼

answered Oct 14 '16 at 04:06 AM

avatar image

Night Watcher
1.7k 43 11 71

avatar image Juice-Tin Oct 14 '16 at 06:04 PM

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

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Jan 19 '19 at 11:56 PM

avatar image

dancode
24 1 4 8

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question