Description

I believe that this is happening because of a problem within USubobjectDataSubsystem::FindOrCreateAttachParentForComponent where it is creating duplicates of the character mesh because the "TestSceneComponent" has not been created yet when the first Character mesh is made. Hopefully we can solve this by adding some more checks on the adding of subobjects to make sure there are no duplicate names. 

Steps to Reproduce

Add the following header file to you project: 

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "FooActor.generated.h"

class USceneComponent;

UCLASS(BlueprintType)
class AFooCharacter : public ACharacter
{
   GENERATED_BODY()

   AFooCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
   
public:    

   UPROPERTY(EditAnywhere, BlueprintReadOnly)
   USceneComponent* TestSceneComp = nullptr;
};

Add the following Cpp to your project: 

// Copyright Epic Games, Inc. All Rights Reserved.

#include "FooActor.h"
#include "Components/SceneComponent.h"

// Sets default values
AFooCharacter::AFooCharacter(const FObjectInitializer& ObjectInitializer)
   : Super(ObjectInitializer)
{
   // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
   PrimaryActorTick.bCanEverTick = true;

   TestSceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("TestSceneCompName"));
   GetMesh()->SetupAttachment(TestSceneComp);
}

1. Create a BP based on FooCharacter

2. Open the blueprint

 

Result: There are two "CharacterMesh" skeletal mesh components, one with an incorrect attachment.

Expected: there is only one skeletal mesh, and it is attached to the "TestSceneComp" 

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-155798 in the post.

1
Login to Vote

Fixed
ComponentUE - Gameplay - Components
Affects Versions5.05.1
Target Fix5.1
Fix Commit22121680
Main Commit22141891
Release Commit22121680
CreatedJun 3, 2022
ResolvedSep 21, 2022
UpdatedOct 21, 2022
View Jira Issue