[C++]: Adding actors to character: Root Comment:

The character in our game has abilities and weapons that are Actors. We spawn them and such, but I know we are doing something wrong because when play with 2 players simulated. The game crashes, and the abilities only work on the player initialized first. For the newest Weapon I’ve added the game crashes when the component is added for the second player. Below is some of the output relevant to the

 [2016.02.22-02.00.24:400][669]LogActor:Warning: BP_AugGrap_Proto_C /Game/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.PrimaryAugmentation has natively added scene component(s), but none of them were set as the actor's RootComponent - picking one arbitrarily
    [2016.02.22-02.00.24:400][669]PIE:Warning: Warning AttachTo: '/Game/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.PrimaryAugmentation.DefaultSceneRoot' cannot be attached to itself. Aborting.
    [2016.02.22-02.00.24:400][669]LogActor:Warning: BP_Aug_Test_C /Game/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.SecondaryAugmentation has natively added scene component(s), but none of them were set as the actor's RootComponent - picking one arbitrarily
    [2016.02.22-02.00.24:400][669]PIE:Warning: Warning AttachTo: '/Game/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.SecondaryAugmentation.DefaultSceneRoot' cannot be attached to itself. Aborting.
    [2016.02.22-02.00.24:400][669]LogActor:Warning: BP_Grenade_Base_C /Game/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.Grenade has natively added scene component(s), but none of them were set as the actor's RootComponent - picking one arbitrarily
    [2016.02.22-02.00.24:401][669]PIE:Warning: Warning AttachTo: '/Game/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.Grenade.DefaultSceneRoot' cannot be attached to itself. Aborting.

So, I know I’m messing up somewhere, but am not sure where. Any ideas?

PrimaryAugmentation has natively added scene component(s), but none of them were set as the actor’s RootComponent - picking one arbitrarily

You need to set at least one component as the root in your constructor. For example assuming you’ve defined a
scenecomponent like this in the header:

UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Translation)
	USceneComponent* SceneComponent;

then you would use the following in your constructor to set it as root:

SceneComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneComp"));
SceneComponent->Mobility = EComponentMobility::Static;
RootComponent = SceneComponent;

As for the second message:

PrimaryAugmentation.DefaultSceneRoot' cannot be attached to itself. Aborting.

This is a bit of a contradiction though as it looks like someone is trying to set DefaultSceneRoot as the component eg:RootComponent = DefaultSceneRoot; (maybe the engine is doing this on its own because you didn’t supply a root component?) and then attaching that component back to root later, eg: DefaultSceneRoot->AttachTo(RootComponent);

Try explicitly setting your rootcomponent first.

If that doesn’t work my question to you would be whether “DefaultSceneRoot” is something you’ve added on your own (eg: from a parent class constructor) or is it coming from a blueprint that you have subclassed from your custom actor?

HTH

Adding that code, even without setting SceneComponent resolved the error. Thank you!