Download

Attaching camera to a socket

Hi, I tried attaching camera to a socket on the mesh. For some reason it doesn’t seem to be working.

I edited the 3rd person template code for it.


	// Create a camera boom (pulls in towards the player if there is a collision)
	CameraBoom = PCIP.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
	CameraBoom->AttachTo(Mesh, "FirePoint");
	CameraBoom->TargetArmLength = 0.0f; // The camera follows at this distance behind the character	
	CameraBoom->bUseControllerViewRotation = true; // Rotate the arm based on the controller

	// Create a follow camera
	FollowCamera = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FollowCamera"));
	FollowCamera->AttachTo(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
	FollowCamera->bUseControllerViewRotation = false; // Camera does not rotate relative to arm

This is the location of the socket
bf5007feaed9eb9645ea37c6f1fa33034f267b94.jpeg

The camera is getting attached to the chest for some reason.
b804468b4227278464e560565bc221252d5d53a1.jpeg

Did you try attaching the camera directly, rather than using a boom at all, more like the first person template?

Tried same thing happens


	FollowCamera = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FollowCamera"));
	FollowCamera->AttachTo(Mesh, "FirePoint");
	//FollowCamera->AttachTo(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
	FollowCamera->bUseControllerViewRotation = false; // Camera does not rotate relative to arm

Try following the steps here and see how you go:
Wiki: Oculus_Rift#True_First_Person_Viewpoint