Added Shotgun Functionality Firing
This commit is contained in:
parent
425ceb05d0
commit
a790a4a790
@ -2,9 +2,42 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "ShotgunClass.h"
|
#include "ShotgunClass.h"
|
||||||
|
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
||||||
|
#include "Engine/DamageEvents.h"
|
||||||
|
|
||||||
AShotgunClass::AShotgunClass()
|
AShotgunClass::AShotgunClass()
|
||||||
{
|
{
|
||||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AShotgunClass::Fire()
|
||||||
|
{
|
||||||
|
if(currentAmmoCount > 0)
|
||||||
|
{
|
||||||
|
traceStart = GunStartArrow->GetComponentLocation();
|
||||||
|
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, FVector(10,10,10));
|
||||||
|
traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance);
|
||||||
|
GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams);
|
||||||
|
DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Red , false, 100.f, 0U, 1.f);
|
||||||
|
currentAmmoCount --;
|
||||||
|
}
|
||||||
|
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
|
||||||
|
GenerateRecoilVector();
|
||||||
|
ClickDetectionTimer();
|
||||||
|
bulletCountShoot += 1;
|
||||||
|
bStopShooting = false;
|
||||||
|
if (outHit.bBlockingHit)
|
||||||
|
{
|
||||||
|
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||||
|
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(currentAmmoCount <= 0)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,5 +17,8 @@ class ENDLESSVENDETTA_API AShotgunClass : public ABaseWeaponClass
|
|||||||
public:
|
public:
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
AShotgunClass();
|
AShotgunClass();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Fire() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user