Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. void ABulletBase::OnHit(UPrimitiveComponent* OnComponentHit, UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
  2. {
  3. if (!OtherActor)
  4. {
  5. return;
  6. }
  7.  
  8. AWeaponBase* MyGun = Cast<AWeaponBase>(GetOwner());
  9. float DamageToDeal;
  10.  
  11. if (MyGun)
  12. {
  13. DamageToDeal = MyGun->Damage;
  14. }
  15. else
  16. {
  17. DamageToDeal = 50;
  18. }
  19.  
  20. float DamageMultiplier = 1.0;
  21. if (Hit.BoneName == TEXT("Head"))
  22. {
  23. float DamageMultiplier = 2.0;
  24. }
  25.  
  26. const float FinalDamage = DamageToDeal * DamageMultiplier;
  27.  
  28. UGameplayStatics::ApplyDamage(OtherActor, FinalDamage, nullptr, GetOwner(), UDamageType::StaticClass());
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement