212 - Projectile Head Shots
This commit is contained in:
parent
0d5eb1b16d
commit
9b45b23dfd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -22,9 +22,19 @@ public:
|
||||||
FVector_NetQuantize100 InitialVelocity;
|
FVector_NetQuantize100 InitialVelocity;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float InitialSpeed = 15000;
|
float InitialSpeed = 25000;
|
||||||
|
|
||||||
|
// SSR will get Damage directly from the weapon
|
||||||
|
// Non SSR, Damage will be set from the weapon
|
||||||
|
// Only set this for Grenades and Rockets
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
float Damage = 20.f;
|
float Damage = 20.f;
|
||||||
|
|
||||||
|
// SSR will get Damage directly from the weapon
|
||||||
|
// Non SSR, Damage will be set from the weapon
|
||||||
|
// Doesn't matter for Grenades and rockets
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float HeadShotDamage = 40.f;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
|
@ -46,7 +46,9 @@ void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor,
|
||||||
{
|
{
|
||||||
if (OwnerCharacter->HasAuthority() && !bUseServerSideRewind)
|
if (OwnerCharacter->HasAuthority() && !bUseServerSideRewind)
|
||||||
{
|
{
|
||||||
UGameplayStatics::ApplyDamage(OtherActor, Damage, OwnerController, this, UDamageType::StaticClass());
|
const float DamageToCause = Hit.BoneName.ToString() == FString("head") ? HeadShotDamage : Damage;
|
||||||
|
|
||||||
|
UGameplayStatics::ApplyDamage(OtherActor, DamageToCause, OwnerController, this, UDamageType::StaticClass());
|
||||||
Super::OnHit(HitComp, OtherActor, OtherComp, NormalImpulse, Hit);
|
Super::OnHit(HitComp, OtherActor, OtherComp, NormalImpulse, Hit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ void AProjectileWeapon::Fire(const FVector& HitTarget)
|
||||||
{
|
{
|
||||||
FTransform SocketTransform = MuzzleFlashSocket->GetSocketTransform(GetWeaponMesh());
|
FTransform SocketTransform = MuzzleFlashSocket->GetSocketTransform(GetWeaponMesh());
|
||||||
// From muzzle flash socket to hit location from TraceUnderCrosshairs
|
// From muzzle flash socket to hit location from TraceUnderCrosshairs
|
||||||
FVector ToTarget = HitTarget - SocketTransform.GetLocation();
|
const FVector ToTarget = HitTarget - SocketTransform.GetLocation();
|
||||||
FRotator TargetRotation = ToTarget.Rotation();
|
const FRotator TargetRotation = ToTarget.Rotation();
|
||||||
|
|
||||||
FActorSpawnParameters SpawnParams;
|
FActorSpawnParameters SpawnParams;
|
||||||
SpawnParams.Owner = GetOwner();
|
SpawnParams.Owner = GetOwner();
|
||||||
|
@ -34,6 +34,7 @@ void AProjectileWeapon::Fire(const FVector& HitTarget)
|
||||||
SpawnedProjectile = World->SpawnActor<AProjectile>(ProjectileClass, SocketTransform.GetLocation(), TargetRotation, SpawnParams);
|
SpawnedProjectile = World->SpawnActor<AProjectile>(ProjectileClass, SocketTransform.GetLocation(), TargetRotation, SpawnParams);
|
||||||
SpawnedProjectile->bUseServerSideRewind = false;
|
SpawnedProjectile->bUseServerSideRewind = false;
|
||||||
SpawnedProjectile->Damage = Damage;
|
SpawnedProjectile->Damage = Damage;
|
||||||
|
SpawnedProjectile->HeadShotDamage = HeadShotDamage;
|
||||||
}
|
}
|
||||||
else // Server, not locally controlled - spawn non-replicated projectile, SSR
|
else // Server, not locally controlled - spawn non-replicated projectile, SSR
|
||||||
{
|
{
|
||||||
|
@ -64,6 +65,7 @@ void AProjectileWeapon::Fire(const FVector& HitTarget)
|
||||||
SpawnedProjectile = World->SpawnActor<AProjectile>(ProjectileClass, SocketTransform.GetLocation(), TargetRotation, SpawnParams);
|
SpawnedProjectile = World->SpawnActor<AProjectile>(ProjectileClass, SocketTransform.GetLocation(), TargetRotation, SpawnParams);
|
||||||
SpawnedProjectile->bUseServerSideRewind = false;
|
SpawnedProjectile->bUseServerSideRewind = false;
|
||||||
SpawnedProjectile->Damage = Damage;
|
SpawnedProjectile->Damage = Damage;
|
||||||
|
SpawnedProjectile->HeadShotDamage = HeadShotDamage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue