Cannot get the child gun to attach to its socket

I’m not sure exactly what the issue is here. Everything works up to actually getting the object to parent to its socket.

The code is 1:1 (even just blocked out my own code and pasted the one from the github to see if that would work) .cpp:

void AShooterCharacter::BeginPlay()
{
	Super::BeginPlay();
	
	/*Gun = GetWorld()->SpawnActor<AGun>(GunClass);
	GetMesh()->HideBoneByName(TEXT("weapon_r"), EPhysBodyOp::PBO_None);
	Gun->AttachToComponent(GetMesh(), FAttachmentTransformRules::KeepRelativeTransform, TEXT("WeaponSocket"));
	Gun->SetOwner(this);*/

	Gun = GetWorld()->SpawnActor<AGun>(GunClass);
	GetMesh()->HideBoneByName(TEXT("weapon_r"), EPhysBodyOp::PBO_None);
	Gun->AttachToComponent(GetMesh(), FAttachmentTransformRules::KeepRelativeTransform, TEXT("WeaponSocket"));
	Gun->SetOwner(this);

}

And here is the socket in the bone hierarchy:

Everything else is set up properly and works properly. The original gun from the mesh is hidden while the BP rifle does spawn in the world. It just will not stick itself into the designated socket. Tried restarting and recompiling… Nothing’s doing.

I think this is a clue as to what’s going on. You can see that the origin is highlighted on the socket of the character on the translating tool thing but the Actor itself has some kind of crazy offest. You can even see it moving around as the idle animation plays.

Never mind. Close this, please. No idea why or how this happened but I seemed to have two editors open somehow. In one, the gun is never in the right spot. In the other, it’s fine.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms