Skip to content

Instantly share code, notes, and snippets.

@theresajayne
Created January 21, 2019 11:41
Show Gist options
  • Save theresajayne/0679387bcfe6d2474c69df319c4d732f to your computer and use it in GitHub Desktop.
Save theresajayne/0679387bcfe6d2474c69df319c4d732f to your computer and use it in GitHub Desktop.
void ABaseCharacter::StartFire()
{
ABasePlayerController* controller = Cast<ABasePlayerController>(Controller);
if (!controller || !controller->IsGameInputAllowed())
return;
// TODO this will need tweaking for high latency situations (client decision only for now)
if (myWeapon)
{
FHitResult OutHit;
FVector start = myCamera->GetComponentLocation();
FVector end = start + myCamera->GetForwardVector() * 100000.0f;
FCollisionQueryParams CollisionParams;
CollisionParams.AddIgnoredActor(this);
CollisionParams.AddIgnoredActor(myWeapon);
FCollisionResponseParams CollisionResponseParams;
if (GetWorld()->SweepSingleByChannel(OutHit, start, end, FQuat::Identity, ECollisionChannel::ECC_Visibility, FCollisionShape::MakeSphere(5.0f), CollisionParams, CollisionResponseParams))
myWeapon->Fire(OutHit.Location);
else
myWeapon->Fire(end);
}
}
void ABaseCharacter::StopFire()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment