diff --git a/Content/Assets/MilitaryWeapSilver/Weapons/AssaultRifleA_Ammo.uasset b/Content/Assets/MilitaryWeapSilver/Weapons/AssaultRifleA_Ammo.uasset index f43ecd4..7e2b4b5 100644 Binary files a/Content/Assets/MilitaryWeapSilver/Weapons/AssaultRifleA_Ammo.uasset and b/Content/Assets/MilitaryWeapSilver/Weapons/AssaultRifleA_Ammo.uasset differ diff --git a/Content/Assets/MilitaryWeapSilver/Weapons/Materials/M_Ammo.uasset b/Content/Assets/MilitaryWeapSilver/Weapons/Materials/M_Ammo.uasset new file mode 100644 index 0000000..ed67a5b Binary files /dev/null and b/Content/Assets/MilitaryWeapSilver/Weapons/Materials/M_Ammo.uasset differ diff --git a/Content/Assets/MilitaryWeapSilver/Weapons/Materials/M_WeaponMaster_01.uasset b/Content/Assets/MilitaryWeapSilver/Weapons/Materials/M_WeaponMaster_01.uasset index 447924c..6bf7d33 100644 Binary files a/Content/Assets/MilitaryWeapSilver/Weapons/Materials/M_WeaponMaster_01.uasset and b/Content/Assets/MilitaryWeapSilver/Weapons/Materials/M_WeaponMaster_01.uasset differ diff --git a/Content/Assets/Sounds/Shells/Shells_Att.uasset b/Content/Assets/Sounds/Shells/Shells_Att.uasset new file mode 100644 index 0000000..7e9e710 Binary files /dev/null and b/Content/Assets/Sounds/Shells/Shells_Att.uasset differ diff --git a/Content/Assets/Sounds/Shells/Shells_Cue.uasset b/Content/Assets/Sounds/Shells/Shells_Cue.uasset new file mode 100644 index 0000000..12a1b0f Binary files /dev/null and b/Content/Assets/Sounds/Shells/Shells_Cue.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_03_wav.uasset b/Content/Assets/Sounds/Shells/shell_03_wav.uasset new file mode 100644 index 0000000..e5044af Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_03_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_04_wav.uasset b/Content/Assets/Sounds/Shells/shell_04_wav.uasset new file mode 100644 index 0000000..3935613 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_04_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_10_wav.uasset b/Content/Assets/Sounds/Shells/shell_10_wav.uasset new file mode 100644 index 0000000..48bf6b5 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_10_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_12_wav.uasset b/Content/Assets/Sounds/Shells/shell_12_wav.uasset new file mode 100644 index 0000000..417e378 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_12_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_13_wav.uasset b/Content/Assets/Sounds/Shells/shell_13_wav.uasset new file mode 100644 index 0000000..14fea66 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_13_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_14_wav.uasset b/Content/Assets/Sounds/Shells/shell_14_wav.uasset new file mode 100644 index 0000000..4cf3d86 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_14_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_16_wav.uasset b/Content/Assets/Sounds/Shells/shell_16_wav.uasset new file mode 100644 index 0000000..38b58ac Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_16_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_17_wav.uasset b/Content/Assets/Sounds/Shells/shell_17_wav.uasset new file mode 100644 index 0000000..855d8bb Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_17_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_21_wav.uasset b/Content/Assets/Sounds/Shells/shell_21_wav.uasset new file mode 100644 index 0000000..ef2a2be Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_21_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_22_wav.uasset b/Content/Assets/Sounds/Shells/shell_22_wav.uasset new file mode 100644 index 0000000..f072f80 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_22_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_25_wav.uasset b/Content/Assets/Sounds/Shells/shell_25_wav.uasset new file mode 100644 index 0000000..6ee86b8 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_25_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_26_wav.uasset b/Content/Assets/Sounds/Shells/shell_26_wav.uasset new file mode 100644 index 0000000..c80cf42 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_26_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_32_wav.uasset b/Content/Assets/Sounds/Shells/shell_32_wav.uasset new file mode 100644 index 0000000..8613935 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_32_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_42_wav.uasset b/Content/Assets/Sounds/Shells/shell_42_wav.uasset new file mode 100644 index 0000000..b2ab86c Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_42_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_44_wav.uasset b/Content/Assets/Sounds/Shells/shell_44_wav.uasset new file mode 100644 index 0000000..c97ef99 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_44_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_45_wav.uasset b/Content/Assets/Sounds/Shells/shell_45_wav.uasset new file mode 100644 index 0000000..f545594 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_45_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_47_wav.uasset b/Content/Assets/Sounds/Shells/shell_47_wav.uasset new file mode 100644 index 0000000..f592785 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_47_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_55_wav.uasset b/Content/Assets/Sounds/Shells/shell_55_wav.uasset new file mode 100644 index 0000000..77db6cb Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_55_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_59_wav.uasset b/Content/Assets/Sounds/Shells/shell_59_wav.uasset new file mode 100644 index 0000000..b99cf42 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_59_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_60_wav.uasset b/Content/Assets/Sounds/Shells/shell_60_wav.uasset new file mode 100644 index 0000000..2aa8bc4 Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_60_wav.uasset differ diff --git a/Content/Assets/Sounds/Shells/shell_61_wav.uasset b/Content/Assets/Sounds/Shells/shell_61_wav.uasset new file mode 100644 index 0000000..4b85edf Binary files /dev/null and b/Content/Assets/Sounds/Shells/shell_61_wav.uasset differ diff --git a/Content/Blueprints/Character/BP_BlasterCharacter.uasset b/Content/Blueprints/Character/BP_BlasterCharacter.uasset index 624bf64..8895600 100644 Binary files a/Content/Blueprints/Character/BP_BlasterCharacter.uasset and b/Content/Blueprints/Character/BP_BlasterCharacter.uasset differ diff --git a/Content/Blueprints/Weapon/Casings/BP_Casing.uasset b/Content/Blueprints/Weapon/Casings/BP_Casing.uasset index 0f73bc1..c8264b9 100644 Binary files a/Content/Blueprints/Weapon/Casings/BP_Casing.uasset and b/Content/Blueprints/Weapon/Casings/BP_Casing.uasset differ diff --git a/Source/Blaster/Weapon/Casing.cpp b/Source/Blaster/Weapon/Casing.cpp index e0a5670..19ed785 100644 --- a/Source/Blaster/Weapon/Casing.cpp +++ b/Source/Blaster/Weapon/Casing.cpp @@ -3,18 +3,42 @@ #include "Casing.h" +#include "Kismet/GameplayStatics.h" +#include "Sound/SoundCue.h" + ACasing::ACasing() { PrimaryActorTick.bCanEverTick = false; + ShellEjectionImpulseMin = 8.f; + ShellEjectionImpulseMax = 12.f; CasingMesh = CreateDefaultSubobject(TEXT("CasingMesh")); + CasingMesh->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore); + CasingMesh->SetSimulatePhysics(true); + CasingMesh->SetEnableGravity(true); + CasingMesh->SetNotifyRigidBodyCollision(true); SetRootComponent(CasingMesh); } void ACasing::BeginPlay() { Super::BeginPlay(); - + + CasingMesh->OnComponentHit.AddDynamic(this, &ACasing::OnHit); + CasingMesh->AddImpulse(GetActorForwardVector() * FMath::RandRange(ShellEjectionImpulseMin, ShellEjectionImpulseMax)); + + SetLifeSpan(5.f); +} + +void ACasing::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) +{ + if (ShellSound) + { + UGameplayStatics::PlaySoundAtLocation(this, ShellSound, GetActorLocation()); + } + + // Disable hit event so that sound won't play multiple times + CasingMesh->SetNotifyRigidBodyCollision(false); } diff --git a/Source/Blaster/Weapon/Casing.h b/Source/Blaster/Weapon/Casing.h index 7271471..dac4653 100644 --- a/Source/Blaster/Weapon/Casing.h +++ b/Source/Blaster/Weapon/Casing.h @@ -16,9 +16,21 @@ public: protected: virtual void BeginPlay() override; + UFUNCTION() + virtual void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit); + private: UPROPERTY(VisibleAnywhere) UStaticMeshComponent* CasingMesh; + + UPROPERTY(EditAnywhere) + float ShellEjectionImpulseMin; + + UPROPERTY(EditAnywhere) + float ShellEjectionImpulseMax; + + UPROPERTY(EditAnywhere) + class USoundCue* ShellSound; };