FinishSpawning is not called for Actor after recompilation

I spawn weapon actor and attach it to my character in PostInitializeComponents so it can be viewed in blueprint editor, but it disappears after I hit Compile, and I must reopen blueprint editor to see it again. I figured out that it’s due to FinishSpawning not being called for character actor after recompilation. Is it intended behaviour?

Hi ,

  • Does this occur in a clean, blank project with no additional content or is it limited to one project?
  • Where are you spawning/initializing the weapon actor?

Greetings,

I’ve just managed to reproduce this situation in a blank project. As I’ve mentioned earlier, I spawn the weapon actor in my character’s PostInitializeComponents() method.

Hello ,

Is there a particular reason that the weapon needs to be a separate actor? If so, would it be better to have it already exist and then have it attached to the character? It could also be made into a component that you add to the character instead. Otherwise, PostInitializeComponents, as with BeginPlay, is for gameplay purposes. If you’re looking for something that updates in the editor, you would need to use PostInitProperties. You can find more information about the differences here: Acotr in Editor - what events are fired. - C++ - Epic Developer Community Forums

Here’s a link to the test project. Repro steps:

  1. Open MyTestCharacter blueprint.
  2. Open Full Blueprint Editor.
  3. Switch to Viewport.
  4. Change any property.
  5. Compile.
  6. The weapon actor disappears.

Hi ,

Thanks, I guess PostInitProperties is what I was looking for. But then, is it okay that PostInitializeComponents is called the first time I open blueprint editor (while BeginPlay is not)? It’s kinda confusing.

PostInitializeComponents is supposed to be called whenever a component is initialized as it says, which does happen upon opening the editor and the blueprint editor itself. After tinkering a bit more with your project however by adding some log messages to PostEditChangeProperty and PostInitializeComponent, it seems like your code in PostEditChangeProperty is what is causing the weapon to disappear. It’s called whenever compile is ran and after commenting out the code that it contained (except for the Super::slight_smile: the weapon doesn’t disappear upon compile anymore.

I tried to comment out PostEditChangeProperty like you said, but the weapon still disappears. Anyway, thanks, I think I’ll stick with PostInitProperties.