I think you should set the RootComponent only in the actor’s constructor.
Also it’s not good at all to access an actor’s components from another actors.
There is a way to make some setup for a spawning actor before spawn is completed, look hee for the upvoted answer. Though I’m sure it’s still not the way to setup the actor’s component. In most cases, components should be created in the actor’s constructor.
Using it doesn’t trigger the ensure condition anymore, SetRootComponent returns a bool to indicate success, but it doesn’t do anything.
I know that it is bad practice to modify unknown Actors from outside. The reason I require this functionality is actually to autocorrect mistakes that inexperienced designers may make when choosing certain configurations. Since the projects are usually short-lived, it is easier to throw a warning and try to guess what the intention of the designer was.
Unfortunately, I don’t know how I could validate that SetRootComponent will crash by using Unreal’s functionality and checking for certain conditions doesn’t work since the involved entities don’t know about each other.