I had problems with PlayerInputComponent->BindAction("Fire", IE_Pressed, Gun, &AGun::OnFire);
as well. When I inserted some UE_LOG statements I discovered is that SetupPlayerInputComponent is called before BeingPlay. What I ended up doing is checking if Gun is null in both so that I could attach the gun separately.
Sorry about the formatting, what tags do I use for code?? Also, why are edits showing up as replies???
if (Gun == NULL) {
AttachGun();
}
–//–
void AFirstPersonCharacter::AttachGun() {
UE_LOG(LogTemp, Warning, TEXT("---------- Attaching Gun ----------"));
Gun = GetWorld()->SpawnActor<AGun>(GunBlueprint);
Gun->AttachToComponent(Mesh1P, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), TEXT("GripPoint"));
Gun->AnimInstance = Mesh1P->GetAnimInstance();
}