Hi, so this code when called in the constructor sets the parent for my gun to be the “Hands” skeletal mesh, but it does not set it as a child to the bone named “hand_l”.
Gun->SetupAttachment(Hands, TEXT("hand_l"));
When i call
Gun->AttachToComponent(Hands, FAttachmentTransformRules::SnapToTargetNotIncludingScale, TEXT("hand_l"));
inside the BeginPlay event, it detects the bone and it attaches to it. When i call this line of code inside the constructor, the game just crashes.
My problem is that i cannot edit the default location and the rotation of the gun inside the blueprint editor if i set the parent bone in the BeginPlay, and making it look right is tricky using “SetRelativeTransform” (the gun should look like it is in the player’s hand). Any ideea what am i doing wrong or why the bone socket is not being detected inside the constructor?