Added a temporary weapon damage for Damage Fall Off
This commit is contained in:
parent
0608015705
commit
34ef5c6e40
@ -23,7 +23,7 @@ ABaseWeaponClass::ABaseWeaponClass()
|
||||
void ABaseWeaponClass::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
tempWeaponDamage = WeaponDamage;
|
||||
collisionParams.AddIgnoredActor(playerInWorld);
|
||||
collisionParams.AddIgnoredActor(this);
|
||||
|
||||
|
@ -180,12 +180,10 @@ protected:
|
||||
UArrowComponent* GunStartArrow;
|
||||
bool bStopShooting = false;
|
||||
|
||||
private:
|
||||
int tempWeaponDamage;
|
||||
|
||||
float originalMagnitude;
|
||||
float originalMaxAngleLeft;
|
||||
float originalMaxAngleRight;
|
||||
float originalMinMultiplier;
|
||||
|
||||
|
||||
};
|
||||
|
@ -9,6 +9,12 @@ AShotgunClass::AShotgunClass()
|
||||
{
|
||||
// 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;
|
||||
ShotgunBulletSpread = FVector(10,10,10);
|
||||
}
|
||||
|
||||
void AShotgunClass::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void AShotgunClass::Fire()
|
||||
@ -19,8 +25,17 @@ void AShotgunClass::Fire()
|
||||
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, FVector(10,10,10));
|
||||
FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, ShotgunBulletSpread);
|
||||
traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance);
|
||||
if (outHit.Distance >= FMath::Floor(BulletDistance/1.5))
|
||||
{
|
||||
tempWeaponDamage /= 2;
|
||||
GLog->Log("Bullet distance reached a quarter");
|
||||
}
|
||||
else
|
||||
{
|
||||
tempWeaponDamage = WeaponDamage;
|
||||
}
|
||||
GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams);
|
||||
DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Red , false, 100.f, 0U, 1.f);
|
||||
currentAmmoCount --;
|
||||
@ -41,3 +56,4 @@ void AShotgunClass::Fire()
|
||||
UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,13 @@ public:
|
||||
// Sets default values for this actor's properties
|
||||
AShotgunClass();
|
||||
|
||||
//How far apart the bullets will be to eachother when shot with a shotgun
|
||||
UPROPERTY(EditAnywhere, Category = "Weapon")
|
||||
FVector ShotgunBulletSpread;
|
||||
|
||||
protected:
|
||||
virtual void Fire() override;
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user