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->SetNotifyRigidBodyCollision(true);
|
||||
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
|
||||
|
|
|
@ -17,9 +17,8 @@ public:
|
|||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, meta = (ClampMin = "0.0", ClampMax = "1.0"))
|
||||
float ImpulseAngle = 0.5f;
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||
USphereComponent* SphereComponent;
|
||||
|
||||
public:
|
||||
|
|
|
@ -28,8 +28,8 @@ class NAKATOMI_API AWeapon : public AActor
|
|||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
public:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||
USkeletalMeshComponent* WeaponSkeletalMeshComponent;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
AWeaponThrowable::AWeaponThrowable()
|
||||
{
|
||||
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh Component"));
|
||||
WeaponSkeletalMeshComponent->SetCollisionProfileName(FName("BlockAll"));
|
||||
WeaponSkeletalMeshComponent->SetCollisionProfileName(FName("OverlapAll"));
|
||||
WeaponSkeletalMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
||||
WeaponSkeletalMeshComponent->SetCollisionObjectType(ECC_WorldDynamic);
|
||||
WeaponSkeletalMeshComponent->SetSimulatePhysics(true);
|
||||
|
@ -22,7 +22,7 @@ void AWeaponThrowable::BeginPlay()
|
|||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
WeaponSkeletalMeshComponent->OnComponentHit.AddDynamic(this, &AWeaponThrowable::OnOverlapBegin);
|
||||
WeaponSkeletalMeshComponent->OnComponentBeginOverlap.AddDynamic(this, &AWeaponThrowable::OnSphereBeginOverlap);
|
||||
|
||||
auto playerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
|
||||
auto playerForwardVector = playerCharacter->GetActorForwardVector();
|
||||
|
@ -43,3 +43,20 @@ void AWeaponThrowable::SetWeaponSkeletalMesh(USkeletalMesh* SkeletalMesh)
|
|||
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:
|
||||
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