if i spawn my weapon is is not visibol (a sepered class) is i do a debug prind string in the bluprind it shows up
//Create FPS camera component.
FPSCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
check(FPSCameraComponent != nullptr);
//Attach the camera component to our capsule component
FPSCameraComponent->SetupAttachment(CastChecked<USceneComponent, UCapsuleComponent>(GetCapsuleComponent()));
// position the camera slightly above the eyes.
FPSCameraComponent->SetRelativeLocation(FVector(0.0f,0.0f,50.0f + BaseEyeHeight));
// Enable the pawn to control the camera rotation.
FPSCameraComponent->bUsePawnControlRotation = true;
FPSMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("FirstPersonMesh"));
check(FPSMesh != nullptr);
// Only the owning player sees this mesh.
FPSMesh->SetOnlyOwnerSee(true);
// Attach the FPS mesh to the FPS camera.
FPSMesh-> SetupAttachment(FPSCameraComponent);
// Disable some environmental shadows to preserve the illusion of having a single mesh.
FPSMesh->bCastDynamicShadow = false;
FPSMesh->CastShadow = false;
// The owning player doesn't see the regular (third-person) body mesh.
GetMesh()->SetOwnerNoSee(true);
/***************************************/
/****************Weapon*****************/
/***************************************/
void AFPS_Character_Base::SpawnDefaultWeapon() const
{
if (DefaultWeaponClass)
{
//Debug
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("Weapon add"));
AWeapon_Base* DefaultWeapon = GetWorld()->SpawnActor<AWeapon_Base>(DefaultWeaponClass);
const USkeletalMeshSocket* HandSocket = GetMesh()->GetSocketByName(FName("WeaponSocket"));
if (HandSocket)
{
HandSocket->AttachActor(DefaultWeapon, GetMesh());
}
}
}