blaster/Source/Blaster/Weapon/Shotgun.cpp

30 lines
828 B
C++
Raw Normal View History

2022-05-20 10:10:21 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "Shotgun.h"
#include "Blaster/Character/BlasterCharacter.h"
#include "Engine/SkeletalMeshSocket.h"
#include "Kismet/GameplayStatics.h"
void AShotgun::Fire(const FVector& HitTarget)
{
AWeapon::Fire(HitTarget);
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if (OwnerPawn == nullptr) return;
AController* InstigatorController = OwnerPawn->GetController();
const USkeletalMeshSocket* MuzzleFlashSocket = GetWeaponMesh()->GetSocketByName("MuzzleFlash");
if (MuzzleFlashSocket)
{
FTransform SocketTransform = MuzzleFlashSocket->GetSocketTransform(GetWeaponMesh());
FVector Start = SocketTransform.GetLocation();
for (uint32 i = 0; i < NumberOfPellets; i++)
{
FVector End = TraceEndWithScatter(Start, HitTarget);
}
}
}