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.
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"
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-155798 in the post.
1 |
Component | UE - Gameplay - Components |
---|---|
Affects Versions | 5.0, 5.1 |
Target Fix | 5.1 |
Created | Jun 3, 2022 |
---|---|
Resolved | Sep 21, 2022 |
Updated | Oct 21, 2022 |