Beginner question about ::SocketName

I’m watching a tutorial and then came this line:

FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);

I’d like why am I using Socket Name on the scope resolution because I don’t have any function or variable with this name and I couldn’t find anything about this.

Thank you very much

Actually I would love an answer to this too. It feels like I should replace socketName withsomething else because my camera is not working properly

USpringArmComponent::SocketName is static. It’s not really a “Socket” in the sense of static mesh/skeletal mesh sockets, you can look at the spring arm source to see how it’s used.

You can’t do the same for meshes, because the mesh will be null at the time of construction for the class-default object, it’s just an empty component with no mesh unless you also force a default mesh (which is a terrible idea). If you want to attach to sockets, you can wrap that code with something that protects against the CDO, such as:

(!HasAnyFlags(RF_ClassDefaultObject) && MeshComponent->GetStaticMesh())
    MyComponent->SetupAttachment(MeshComponent, FName("SomeSocket"));

Thank you very much for the clarification <3

Ive come across this before, but I have no issues so far when attaching my camera to the springarm just like any other component heirarchy. Is there some advantage to using sockets?

For some reason the SpringArmComponent actually just returns the end-of-arm position for all sockets, even the “None” one - so anything attached to it even if not using the static SocketName presumably is treated as if it was attached via the socket anyway.