Add Impulse Angle and Force variables to Throwables
This commit is contained in:
parent
27fc0d5212
commit
7cdb9b1c69
|
@ -32,7 +32,8 @@ void AThrowable::BeginPlay()
|
|||
SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &AThrowable::OnOverlapBegin);
|
||||
auto playerCharacter = Cast<APlayerCharacter>(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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -21,7 +21,8 @@ void AWeaponThrowable::BeginPlay()
|
|||
|
||||
auto playerCharacter = Cast<APlayerCharacter>(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<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
|
||||
auto playerForwardVector = playerCharacter->GetActorForwardVector();
|
||||
WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector);
|
||||
playerForwardVector.Z = ImpulseAngle;
|
||||
WeaponSkeletalMeshComponent->AddImpulse(playerForwardVector * ImpulseForce);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue