diff --git a/Source/Nakatomi/Throwable.cpp b/Source/Nakatomi/Throwable.cpp index 864de29..93a8ed4 100644 --- a/Source/Nakatomi/Throwable.cpp +++ b/Source/Nakatomi/Throwable.cpp @@ -32,7 +32,8 @@ void AThrowable::BeginPlay() SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &AThrowable::OnOverlapBegin); auto playerCharacter = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); auto playerForwardVector = playerCharacter->GetActorForwardVector(); - StaticMeshComponent->AddImpulse(playerForwardVector); + playerForwardVector.Z = ImpulseAngle; + StaticMeshComponent->AddImpulse(playerForwardVector * ImpulseForce); } void AThrowable::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, diff --git a/Source/Nakatomi/Throwable.h b/Source/Nakatomi/Throwable.h index 6d0fe27..b6f58b0 100644 --- a/Source/Nakatomi/Throwable.h +++ b/Source/Nakatomi/Throwable.h @@ -11,6 +11,14 @@ class NAKATOMI_API AThrowable : public AExplosiveActor { GENERATED_BODY() +public: + + UPROPERTY(meta = (ClampMin = "0.0")) + float ImpulseForce = 10000.f; + + UPROPERTY(meta = (ClampMin = "0.0", ClampMax = "1.0")) + float ImpulseAngle = 0.5f; + private: UPROPERTY() diff --git a/Source/Nakatomi/WeaponThrowable.cpp b/Source/Nakatomi/WeaponThrowable.cpp index 892b3d3..4edc2aa 100644 --- a/Source/Nakatomi/WeaponThrowable.cpp +++ b/Source/Nakatomi/WeaponThrowable.cpp @@ -21,7 +21,8 @@ void AWeaponThrowable::BeginPlay() auto playerCharacter = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); auto playerForwardVector = playerCharacter->GetActorForwardVector(); - WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector); + playerForwardVector.Z = ImpulseAngle; + WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector * ImpulseForce); } void AWeaponThrowable::SetWeaponSkeletalMesh(USkeletalMesh* SkeletalMesh) @@ -30,5 +31,6 @@ void AWeaponThrowable::SetWeaponSkeletalMesh(USkeletalMesh* SkeletalMesh) auto playerCharacter = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); auto playerForwardVector = playerCharacter->GetActorForwardVector(); - WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector); + playerForwardVector.Z = ImpulseAngle; + WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector * ImpulseForce); }