MCPcopy Create free account
hub / github.com/DruidMech/MultiplayerCourseBlasterGame / OnHit

Method OnHit

Source/Blaster/Weapon/ProjectileBullet.cpp:37–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35#endif
36
37void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
38{
39 ABlasterCharacter* OwnerCharacter = Cast<ABlasterCharacter>(GetOwner());
40 if (OwnerCharacter)
41 {
42 ABlasterPlayerController* OwnerController = Cast<ABlasterPlayerController>(OwnerCharacter->Controller);
43 if (OwnerController)
44 {
45 if (OwnerCharacter->HasAuthority() && !bUseServerSideRewind)
46 {
47
48 const float DamageToCause = Hit.BoneName.ToString() == FString("head") ? HeadShotDamage : Damage;
49
50 UGameplayStatics::ApplyDamage(OtherActor, DamageToCause, OwnerController, this, UDamageType::StaticClass());
51 Super::OnHit(HitComp, OtherActor, OtherComp, NormalImpulse, Hit);
52 return;
53 }
54 ABlasterCharacter* HitCharacter = Cast<ABlasterCharacter>(OtherActor);
55 if (bUseServerSideRewind && OwnerCharacter->GetLagCompensation() && OwnerCharacter->IsLocallyControlled() && HitCharacter)
56 {
57 OwnerCharacter->GetLagCompensation()->ProjectileServerScoreRequest(
58 HitCharacter,
59 TraceStart,
60 InitialVelocity,
61 OwnerController->GetServerTime() - OwnerController->SingleTripTime
62 );
63 }
64 }
65 }
66
67 Super::OnHit(HitComp, OtherActor, OtherComp, NormalImpulse, Hit);
68}
69
70void AProjectileBullet::BeginPlay()
71{

Callers

nothing calls this directly

Calls 1

GetServerTimeMethod · 0.80

Tested by

no test coverage detected