diff --git a/Content/Assets/MilitaryWeapSilver/Weapons/Assault_Rifle_A.uasset b/Content/Assets/MilitaryWeapSilver/Weapons/Assault_Rifle_A.uasset index f6f08a0..013d82f 100644 Binary files a/Content/Assets/MilitaryWeapSilver/Weapons/Assault_Rifle_A.uasset and b/Content/Assets/MilitaryWeapSilver/Weapons/Assault_Rifle_A.uasset differ diff --git a/Content/Blueprints/Weapon/BP_AssaultRifle.uasset b/Content/Blueprints/Weapon/BP_AssaultRifle.uasset index f356d0d..21fc721 100644 Binary files a/Content/Blueprints/Weapon/BP_AssaultRifle.uasset and b/Content/Blueprints/Weapon/BP_AssaultRifle.uasset differ diff --git a/Content/Blueprints/Weapon/Casings/BP_Casing.uasset b/Content/Blueprints/Weapon/Casings/BP_Casing.uasset new file mode 100644 index 0000000..0f73bc1 Binary files /dev/null and b/Content/Blueprints/Weapon/Casings/BP_Casing.uasset differ diff --git a/Source/Blaster/Weapon/Casing.cpp b/Source/Blaster/Weapon/Casing.cpp new file mode 100644 index 0000000..e0a5670 --- /dev/null +++ b/Source/Blaster/Weapon/Casing.cpp @@ -0,0 +1,20 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Casing.h" + +ACasing::ACasing() +{ + PrimaryActorTick.bCanEverTick = false; + + CasingMesh = CreateDefaultSubobject(TEXT("CasingMesh")); + SetRootComponent(CasingMesh); +} + +void ACasing::BeginPlay() +{ + Super::BeginPlay(); + +} + + diff --git a/Source/Blaster/Weapon/Casing.h b/Source/Blaster/Weapon/Casing.h new file mode 100644 index 0000000..7271471 --- /dev/null +++ b/Source/Blaster/Weapon/Casing.h @@ -0,0 +1,24 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "Casing.generated.h" + +UCLASS() +class BLASTER_API ACasing : public AActor +{ + GENERATED_BODY() + +public: + ACasing(); + +protected: + virtual void BeginPlay() override; + +private: + + UPROPERTY(VisibleAnywhere) + UStaticMeshComponent* CasingMesh; +}; diff --git a/Source/Blaster/Weapon/Weapon.cpp b/Source/Blaster/Weapon/Weapon.cpp index e456805..7c493d6 100644 --- a/Source/Blaster/Weapon/Weapon.cpp +++ b/Source/Blaster/Weapon/Weapon.cpp @@ -3,9 +3,11 @@ #include "Weapon.h" +#include "Casing.h" #include "Blaster/Character/BlasterCharacter.h" #include "Components/SphereComponent.h" #include "Components/WidgetComponent.h" +#include "Engine/SkeletalMeshSocket.h" #include "Net/UnrealNetwork.h" AWeapon::AWeapon() @@ -115,4 +117,22 @@ void AWeapon::Fire(const FVector& HitTarget) { WeaponMesh->PlayAnimation(FireAnimation, false); } + if (CasingClass) + { + const USkeletalMeshSocket* AmmoEjectSocket = WeaponMesh->GetSocketByName(FName("AmmoEject")); + if (AmmoEjectSocket) + { + FTransform SocketTransform = AmmoEjectSocket->GetSocketTransform(WeaponMesh); + + UWorld* World = GetWorld(); + if (World) + { + World->SpawnActor( + CasingClass, + SocketTransform.GetLocation(), + SocketTransform.GetRotation().Rotator() + ); + } + } + } } diff --git a/Source/Blaster/Weapon/Weapon.h b/Source/Blaster/Weapon/Weapon.h index 31dc2af..daaf321 100644 --- a/Source/Blaster/Weapon/Weapon.h +++ b/Source/Blaster/Weapon/Weapon.h @@ -66,6 +66,9 @@ private: UPROPERTY(EditAnywhere, Category= "Weapon Properties") class UAnimationAsset* FireAnimation; + + UPROPERTY(EditAnywhere, Category= "Weapon Properties") + TSubclassOf CasingClass; public: void SetWeaponState(EWeaponState State); FORCEINLINE USphereComponent* GetAreaSphere() const { return AreaSphere; }