Fix Machinegun Throwable
This commit is contained in:
parent
2b5d67346a
commit
2fffd64ae8
BIN
Content/Weapons/FPWeapon/Mesh/SK_FPGun.uasset (Stored with Git LFS)
BIN
Content/Weapons/FPWeapon/Mesh/SK_FPGun.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Weapons/FPWeapon/Mesh/SK_FPGun_Physics.uasset (Stored with Git LFS)
BIN
Content/Weapons/FPWeapon/Mesh/SK_FPGun_Physics.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Weapons/FPWeapon/Mesh/SK_FPGun_PhysicsAsset.uasset (Stored with Git LFS)
BIN
Content/Weapons/FPWeapon/Mesh/SK_FPGun_PhysicsAsset.uasset (Stored with Git LFS)
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/Weapons/Machinegun/Machinegun.uasset (Stored with Git LFS)
BIN
Content/Weapons/Machinegun/Machinegun.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Weapons/Machinegun/MachinegunThrowable.uasset (Stored with Git LFS)
BIN
Content/Weapons/Machinegun/MachinegunThrowable.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -19,6 +19,15 @@ AThrowable::AThrowable()
|
||||||
StaticMeshComponent->SetGenerateOverlapEvents(true);
|
StaticMeshComponent->SetGenerateOverlapEvents(true);
|
||||||
StaticMeshComponent->SetNotifyRigidBodyCollision(true);
|
StaticMeshComponent->SetNotifyRigidBodyCollision(true);
|
||||||
SetRootComponent(StaticMeshComponent);
|
SetRootComponent(StaticMeshComponent);
|
||||||
|
|
||||||
|
SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComponent"));
|
||||||
|
SphereComponent->SetSphereRadius(25.0f, true);
|
||||||
|
SphereComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndProbe);
|
||||||
|
SphereComponent->SetCollisionObjectType(ECC_WorldDynamic);
|
||||||
|
SphereComponent->SetSimulatePhysics(true);
|
||||||
|
SphereComponent->SetGenerateOverlapEvents(true);
|
||||||
|
SphereComponent->SetNotifyRigidBodyCollision(true);
|
||||||
|
SphereComponent->SetupAttachment(RootComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
|
|
|
@ -17,9 +17,8 @@ public:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, meta = (ClampMin = "0.0", ClampMax = "1.0"))
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, meta = (ClampMin = "0.0", ClampMax = "1.0"))
|
||||||
float ImpulseAngle = 0.5f;
|
float ImpulseAngle = 0.5f;
|
||||||
|
|
||||||
protected:
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
USphereComponent* SphereComponent;
|
USphereComponent* SphereComponent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -28,8 +28,8 @@ class NAKATOMI_API AWeapon : public AActor
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||||
USkeletalMeshComponent* WeaponSkeletalMeshComponent;
|
USkeletalMeshComponent* WeaponSkeletalMeshComponent;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
AWeaponThrowable::AWeaponThrowable()
|
AWeaponThrowable::AWeaponThrowable()
|
||||||
{
|
{
|
||||||
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh Component"));
|
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh Component"));
|
||||||
WeaponSkeletalMeshComponent->SetCollisionProfileName(FName("BlockAll"));
|
WeaponSkeletalMeshComponent->SetCollisionProfileName(FName("OverlapAll"));
|
||||||
WeaponSkeletalMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
WeaponSkeletalMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
||||||
WeaponSkeletalMeshComponent->SetCollisionObjectType(ECC_WorldDynamic);
|
WeaponSkeletalMeshComponent->SetCollisionObjectType(ECC_WorldDynamic);
|
||||||
WeaponSkeletalMeshComponent->SetSimulatePhysics(true);
|
WeaponSkeletalMeshComponent->SetSimulatePhysics(true);
|
||||||
|
@ -22,7 +22,7 @@ void AWeaponThrowable::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
WeaponSkeletalMeshComponent->OnComponentHit.AddDynamic(this, &AWeaponThrowable::OnOverlapBegin);
|
WeaponSkeletalMeshComponent->OnComponentBeginOverlap.AddDynamic(this, &AWeaponThrowable::OnSphereBeginOverlap);
|
||||||
|
|
||||||
auto playerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
|
auto playerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
|
||||||
auto playerForwardVector = playerCharacter->GetActorForwardVector();
|
auto playerForwardVector = playerCharacter->GetActorForwardVector();
|
||||||
|
@ -43,3 +43,20 @@ void AWeaponThrowable::SetWeaponSkeletalMesh(USkeletalMesh* SkeletalMesh)
|
||||||
WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector * ImpulseForce);
|
WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector * ImpulseForce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AWeaponThrowable::OnSphereBeginOverlap(UPrimitiveComponent* OverlappedComponent,
|
||||||
|
AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp,
|
||||||
|
int32 OtherBodyIndex,
|
||||||
|
bool bFromSweep,
|
||||||
|
const FHitResult &SweepResult)
|
||||||
|
{
|
||||||
|
if (!OtherActor->ActorHasTag(FName("Player")) && OtherActor != this)
|
||||||
|
{
|
||||||
|
if (HealthComponent)
|
||||||
|
{
|
||||||
|
HealthComponent->TakeDamage(this, HealthComponent->GetMaxHealth(), nullptr,
|
||||||
|
nullptr, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -28,4 +28,13 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SetWeaponSkeletalMesh(USkeletalMesh* SkeletalMesh);
|
void SetWeaponSkeletalMesh(USkeletalMesh* SkeletalMesh);
|
||||||
|
|
||||||
|
private:
|
||||||
|
UFUNCTION()
|
||||||
|
void OnSphereBeginOverlap(UPrimitiveComponent* OverlappedComponent,
|
||||||
|
AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp,
|
||||||
|
int32 OtherBodyIndex,
|
||||||
|
bool bFromSweep,
|
||||||
|
const FHitResult &SweepResult);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue