Section 11: Multiple Weapon Types - Lecture 219

Pistol reload animation
This commit is contained in:
charnet3d 2024-01-16 22:07:51 +01:00
parent d2221d2334
commit d16ac0cef1
32 changed files with 91 additions and 35 deletions

BIN
Content/_Game/Assets/Sounds/Pistol/PistolClipInsert.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/_Game/Assets/Sounds/Pistol/PistolClipRemove.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/_Game/Assets/Sounds/Pistol/PistolFire.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/_Game/Assets/Sounds/Pistol/PistolFire_Cue.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/_Game/Assets/Sounds/Rifle/Pistol_Equip.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/_Game/Maps/DefaultMap.umap (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Content/_Game/Weapons/Meshes/Belica_Pistol.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -94,6 +94,9 @@ void AWeapon::OnConstruction(const FTransform& Transform)
case EWeaponType::EWT_AssaultRifle:
WeaponDataRow = WeaponTableObject->FindRow<FWeaponDataTable>(FName("AssaultRifle"), TEXT(""));
break;
case EWeaponType::EWT_Pistol:
WeaponDataRow = WeaponTableObject->FindRow<FWeaponDataTable>(FName("Pistol"), TEXT(""));
break;
case EWeaponType::EWT_SubmachineGun:
default:
WeaponDataRow = WeaponTableObject->FindRow<FWeaponDataTable>(FName("SubmachineGun"), TEXT(""));
@ -130,6 +133,12 @@ void AWeapon::OnConstruction(const FTransform& Transform)
AutoFireRate = WeaponDataRow->AutoFireRate;
MuzzleFlash = WeaponDataRow->MuzzleFlash;
FireSound = WeaponDataRow->FireSound;
BoneToHide = WeaponDataRow->BoneToHide;
if (BoneToHide != FName(""))
{
GetItemMesh()->HideBoneByName(BoneToHide, EPhysBodyOp::PBO_None);
}
}
if (GetMaterialInstance())
@ -142,3 +151,13 @@ void AWeapon::OnConstruction(const FTransform& Transform)
}
}
}
void AWeapon::BeginPlay()
{
Super::BeginPlay();
if (BoneToHide != FName(""))
{
GetItemMesh()->HideBoneByName(BoneToHide, EPhysBodyOp::PBO_None);
}
}

View File

@ -84,6 +84,9 @@ struct FWeaponDataTable : public FTableRowBase
UPROPERTY(EditAnywhere, BlueprintReadWrite)
USoundCue* FireSound;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName BoneToHide;
};
/**
@ -104,6 +107,8 @@ protected:
virtual void OnConstruction(const FTransform& Transform) override;
virtual void BeginPlay() override;
private:
FTimerHandle ThrowWeaponTimer;
float ThrowWeaponTime;
@ -171,6 +176,10 @@ private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true"))
USoundCue* FireSound;
/** Name of the bone to hide on the weapon mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true"))
FName BoneToHide;
public:
/** Adds an impulse to the weapon */
void ThrowWeapon();

View File

@ -5,6 +5,7 @@ enum class EWeaponType : uint8
{
EWT_SubmachineGun UMETA(DisplayName = "SubmachineGun"),
EWT_AssaultRifle UMETA(DisplayName = "AssaultRifle"),
EWT_Pistol UMETA(DisplayName = "Pistol"),
EWT_MAX UMETA(DisplayName = "DefaultMax"),
};