77 - Bullet Shells
This commit is contained in:
parent
ffa9bfc84c
commit
58df613558
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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<UStaticMeshComponent>(TEXT("CasingMesh"));
|
||||||
|
SetRootComponent(CasingMesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACasing::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
};
|
|
@ -3,9 +3,11 @@
|
||||||
|
|
||||||
#include "Weapon.h"
|
#include "Weapon.h"
|
||||||
|
|
||||||
|
#include "Casing.h"
|
||||||
#include "Blaster/Character/BlasterCharacter.h"
|
#include "Blaster/Character/BlasterCharacter.h"
|
||||||
#include "Components/SphereComponent.h"
|
#include "Components/SphereComponent.h"
|
||||||
#include "Components/WidgetComponent.h"
|
#include "Components/WidgetComponent.h"
|
||||||
|
#include "Engine/SkeletalMeshSocket.h"
|
||||||
#include "Net/UnrealNetwork.h"
|
#include "Net/UnrealNetwork.h"
|
||||||
|
|
||||||
AWeapon::AWeapon()
|
AWeapon::AWeapon()
|
||||||
|
@ -115,4 +117,22 @@ void AWeapon::Fire(const FVector& HitTarget)
|
||||||
{
|
{
|
||||||
WeaponMesh->PlayAnimation(FireAnimation, false);
|
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<ACasing>(
|
||||||
|
CasingClass,
|
||||||
|
SocketTransform.GetLocation(),
|
||||||
|
SocketTransform.GetRotation().Rotator()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,9 @@ private:
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
|
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
|
||||||
class UAnimationAsset* FireAnimation;
|
class UAnimationAsset* FireAnimation;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
|
||||||
|
TSubclassOf<class ACasing> CasingClass;
|
||||||
public:
|
public:
|
||||||
void SetWeaponState(EWeaponState State);
|
void SetWeaponState(EWeaponState State);
|
||||||
FORCEINLINE USphereComponent* GetAreaSphere() const { return AreaSphere; }
|
FORCEINLINE USphereComponent* GetAreaSphere() const { return AreaSphere; }
|
||||||
|
|
Loading…
Reference in New Issue