Hello, I have an issue that has been with me since way back, maybe before 4.9. I noticed it but it didn’t trouble me, today I realized it’s actually impacting my project.
Basically I add a mesh in from C++ in the constructor of my player character as follows (the one pertinent to my question is the one called “Mesh”:
FirstPersonMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("FirstPersonMesh"));
FirstPersonMesh->SetOnlyOwnerSee(true); // only the owning player will see this mesh
FirstPersonMesh->AttachToComponent(FirstPersonCameraComponent, FAttachmentTransformRules::KeepRelativeTransform);
FirstPersonMesh->bCastDynamicShadow = false;
FirstPersonMesh->CastShadow = false;
ThirdPersonMesh = ObjectInitializer.CreateOptionalDefaultSubobject<USkeletalMeshComponent>(this, TEXT("Mesh"));
ThirdPersonMesh->SetOwnerNoSee(true);
ThirdPersonMesh->AttachToComponent(GetCapsuleComponent(), FAttachmentTransformRules::KeepRelativeTransform);
Then when I create a Blueprint that has my C++ class for a parent class, I end up with two copies of this mesh.
I didn’t worry about this when I noticed it because it seemed to have no impact and I assumed it was some sort of ghost in the component window that wasn’t actually causing any execution of code. Then today, I noticed that displays I had in my animation blueprint, were doubling and on closer examination, they both had different values for log displays I was checking. If I comment my mesh creation as shown in the C++ code above, both copies go away. When I iterate within the program to set various values, changes are only reflected in one, the first one I get back when I look up the SkeletalMeshComponent (naturally because I only use index 0), so for example a gun gets assigned to one and not the other, physics changes occur to one and not the other, and worse, both are running discrete copies of the Animation blueprint.
I tried recreating my Blueprint from scratch, and it still ends up with two copies of the Mesh.
What could I be doing to cause two copies of the mesh called “Mesh” to generate in the blueprint from a single CreateDefaultSubobject? As it turns out, one provides me with a shadow for my FirstPersonMesh, so there may be a reason why I did this cluelessly, but it’s disconcerting that I can’t find anywhere in my code where I’m generating it and possibly, the shadow I have been getting all along is merely accidentally leveraging another bug. If it is a bug, I’d like to figure it out since two sets of animation blueprints running seems like a bad idea.