How to set the parent socket?

Hey, i wrote this line to make the camera a child of a mesh and to set the camera’s parent socket to “head”, but in the editor “head” doesn’t seem to appear. And it also does not work when i run the game.

In my experience, setting up attachment like this in the constructor never worked, even though everyone says it should. But it works on BeginPlay(), however.

You can try to set attachment under OnConstruction(), maybe it will return the socket name in the editor, although I’ve never tried it so it’s just speculation.

Hey, should i put OnConstruction() in the header file under public or protected?
I don’t know the difference

Since it a function you need to override, you can look how it’s declared in the parent class. In AActor it’s a public function, so

.h:

public: 
virtual void OnConstruction(const FTransform& Transform) override;

.cpp:

void AMyClass::OnConstruction(const FTransform& Transform) 
{
	Super::OnConstruction(Transform);
// your code here
}

It still does not show up in the editor, so it must be a unreal engine bug or something.
Thank you anyway. You are a good guy

Say what now? You already attached the camera to the socket called “head”. You can see it working in viewport.
If you want to define the socket in blueprint then simply create your camera in blueprint and drag it over mesh and then select parent socket.

I’ve manually placed the camera there… The code does not work