Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ABulletBase::OnHit(UPrimitiveComponent* OnComponentHit, UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
- {
- if (!OtherActor)
- {
- return;
- }
- AWeaponBase* MyGun = Cast<AWeaponBase>(GetOwner());
- float DamageToDeal;
- if (MyGun)
- {
- DamageToDeal = MyGun->Damage;
- }
- else
- {
- DamageToDeal = 50;
- }
- float DamageMultiplier = 1.0;
- if (Hit.BoneName == TEXT("Head"))
- {
- float DamageMultiplier = 2.0;
- }
- const float FinalDamage = DamageToDeal * DamageMultiplier;
- UGameplayStatics::ApplyDamage(OtherActor, FinalDamage, nullptr, GetOwner(), UDamageType::StaticClass());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement