Skip to content

Instantly share code, notes, and snippets.

@javenschuetz
Created July 12, 2020 07:05
Show Gist options
  • Save javenschuetz/c603f683eaf40cda2f253e61bec1e004 to your computer and use it in GitHub Desktop.
Save javenschuetz/c603f683eaf40cda2f253e61bec1e004 to your computer and use it in GitHub Desktop.
attaching not wokring
void AHSCharacterBase::ServerEquipHandheldItem_Implementation(AHSHandHeldItem* HandheldItem)
{
if (!HandheldItem) return;
GEngine->AddOnScreenDebugMessage(4,5, FColor::White, "444");
AHSWeapon* WeaponItem = Cast<AHSWeapon>(HandheldItem);
if (WeaponItem)
{
EquippedWeapon = WeaponItem;
WeaponItem->SetWeaponOwner(this); // todo - possibly not used
// this IS needed. ie, both weapon and character need to call this
GetMesh()->IgnoreActorWhenMoving(WeaponItem, true);
GetCapsuleComponent()->IgnoreActorWhenMoving(WeaponItem, true);
}
HandheldItem->SetPhysicsEnabled(false);
GEngine->AddOnScreenDebugMessage(5,5, FColor::White, "555");
if (HasAuthority())
{
GEngine->AddOnScreenDebugMessage(7,5, FColor::White, "has authority true");
}
const USkeletalMeshSocket* HandSocket;
if (HandheldItem->IsRightHandedItem())
HandSocket = GetMesh()->GetSocketByName("RightHandSocket");
else
HandSocket = GetMesh()->GetSocketByName("LeftHandSocket");
if (!HandSocket) return; // todo - cleanup if this happens
GEngine->AddOnScreenDebugMessage(6,5, FColor::White, "666");
HandSocket->AttachActor(HandheldItem, GetMesh());
USoundCue* EquipSound = HandheldItem->GetEquipSound();
if (EquipSound)
{
UGameplayStatics::PlaySoundAtLocation(this, EquipSound, GetMesh()->GetSocketLocation("LeftHandSocket"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment