Hi, I’ve another problem with the “Learning C++” book…
void AWardCharacterCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
// instantiate the melee weapon if a bp was selected
if (BPMeleeWeapon)
{
MeleeWeapon = GetWorld()->SpawnActor<AWardSword>(BPMeleeWeapon, FVector(), FRotator());
if (MeleeWeapon)
{
const USkeletalMeshSocket* socket = GetMesh()->GetSocketByName("RightHandSocket");
// be sure to use correct
// socket name!
socket->AttachActor(MeleeWeapon, GetMesh());
}
}
}
Ah sorry, I didn’t take the time to read what you were actually trying to do. Yes, GetSocketByName() will return a const socket, so you can’t use that.
errors:
C2653: ‘EAttachmentRule’ isn’t the name of a class or of a space of names
C2039: ‘K2_AttachToActor’: isn’t a member of ‘AActor’
C2065: ‘KeepRelative’: identificator not declared
Ok, so you’re using an even older Engine version. It looks like this API has changed a lot recently. Please always include the Engine version in your post.