Get Socket at Initialization

Hi,

i’m trying to set a CameraComponent to a specific bone an the playercharacters mesh and want to calculate the size of the collision capsule around the player from the size of the players mesh.

I’m trying to do that by accessing the bones of the player characters mesh in his character constructor.
It looks like this :

    FirstPersonCameraComponent->AttachTo(Mesh1P, "HeadEyes");
    
    FVector fMeshBottom = Mesh1P->GetSocketLocation("LeftFootToeBase_End");
    FVector fMeshTop = Mesh1P->GetSocketLocation("HeadTop_End");

The problem is that the mesh is not availible at that time. In my log i get:
LogSkinnedMeshComp:Warning: GetSocketByName(): No SkeletalMesh for CharacterMesh1P

If I try to access the later on, e.g. when I press a button, GetSocketLocation will give me the values i want, but thats to late for my program.

Does anybody know how to circumvent this problem? Maybe by creating a method thats called as soon as the player is fully initialized?

Thanks,
Asgatoril

Don’t do this type of work in the constructor, use AActor::BeginPlay | Unreal Engine Documentation