Merge branch 'WeaponSystem' into BackupBuild
# Conflicts: # EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset # EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp
This commit is contained in:
commit
07b6f9aeac
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:30855616c4941635f2b4e9f78ebe1f4d7b43f219e4ae180257f666326433e4c6
|
||||
size 42742
|
||||
oid sha256:dd6b7d124efa1086acb80f4b16e1d8a0db25e05e081f914d61cfce0bbb4191e9
|
||||
size 42329
|
||||
|
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_GunCameraShake.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_GunCameraShake.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Pistols/BP_BasePistolWeapon.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Pistols/BP_BasePistolWeapon.uasset
(Stored with Git LFS)
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:652402df45503ab3169e329879f397101d9b5bf17551404301cca7b5b292eb68
|
||||
size 62076
|
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WeaonRecoil/AssaultRecoilPattern.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WeaonRecoil/AssaultRecoilPattern.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/WBP_Crosshair.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/WBP_Crosshair.uasset
(Stored with Git LFS)
Binary file not shown.
@ -23,6 +23,9 @@ ABaseWeaponClass::ABaseWeaponClass()
|
||||
void ABaseWeaponClass::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
collisionParams.AddIgnoredActor(playerInWorld);
|
||||
collisionParams.AddIgnoredActor(this);
|
||||
|
||||
// Attempt to find the player character
|
||||
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
|
||||
@ -60,6 +63,13 @@ void ABaseWeaponClass::Tick(float DeltaTime)
|
||||
{
|
||||
ApplyRecoil(DeltaTime);
|
||||
}
|
||||
UE_LOG(LogTemp, Display, TEXT("currnt pitch: %f"), currentPitch);
|
||||
if (currentPitch < 0 && bStopShooting)
|
||||
{
|
||||
float increment = currentPitch * DeltaTime * 8;
|
||||
currentPitch -= increment;
|
||||
playerInWorld->AddControllerPitchInput(-increment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +82,11 @@ void ABaseWeaponClass::GenerateRecoilVector()
|
||||
|
||||
recoilResultYaw = FMath::Sin(FMath::DegreesToRadians(angle));
|
||||
recoilResultPitch = FMath::Cos(FMath::DegreesToRadians(angle));
|
||||
|
||||
|
||||
if (bulletCountShoot >= howMnyShotsTillRclStop)
|
||||
{
|
||||
recoilResultPitch = 0;
|
||||
}
|
||||
//scaling direction to magnitude
|
||||
recoilResultPitch *= -tempMag;
|
||||
recoilResultYaw *= tempMag;
|
||||
@ -87,11 +101,13 @@ void ABaseWeaponClass::ApplyRecoil(float DeltaTime)
|
||||
{
|
||||
float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time
|
||||
recoilTime += DeltaTime;
|
||||
if (bulletCountShoot <= 3) playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime));
|
||||
traceEnd = traceStart + (UKismetMathLibrary::GetForwardVector(playerInWorld->GetControlRotation() * GetRecoilPitch(amplitude, recoilTime)));
|
||||
//UE_LOG(LogTemp, Warning, TEXT("Controller pitch: Pitch: %f Yaw: %f, Roll: %f"), playerInWorld->GetControlRotation().Pitch, playerInWorld->GetControlRotation().Yaw, playerInWorld->GetControlRotation().Roll);
|
||||
if (bulletCountShoot <= 3)
|
||||
{
|
||||
playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime));
|
||||
currentPitch += GetRecoilPitch(amplitude,recoilTime);
|
||||
}
|
||||
GunStartArrow->AddRelativeRotation(FRotator(-GetRecoilPitch(amplitude, recoilTime), 0, 0));
|
||||
playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime));
|
||||
//UE_LOG(LogTemp, Warning, TEXT("recoilTime: %f"), recoilTime);
|
||||
UpdateSamples(amplitude, recoilTime);
|
||||
}
|
||||
}
|
||||
@ -139,8 +155,13 @@ void ABaseWeaponClass::ClickDetectionTimer()
|
||||
void ABaseWeaponClass::CancelFire()
|
||||
{
|
||||
GetWorldTimerManager().ClearTimer(timerHandle);
|
||||
if (bulletCountShoot <= 0) return;
|
||||
UE_LOG(LogTemp, Display, TEXT("FireCancelled"));
|
||||
bulletCountShoot = 0;
|
||||
GunStartArrow->SetRelativeRotation(FRotator(0));
|
||||
//playerInWorld->GetController()->SetControlRotation(FRotator(0, playerInWorld->GetActorRotation().Yaw, playerInWorld->GetActorRotation().Roll));
|
||||
bStopShooting = true;
|
||||
nullSamples();
|
||||
}
|
||||
|
||||
void ABaseWeaponClass::Fire()
|
||||
@ -150,26 +171,17 @@ void ABaseWeaponClass::Fire()
|
||||
//do damage fallof based off distance
|
||||
traceStart = GunStartArrow->GetComponentLocation();
|
||||
traceEnd = traceStart + (GunStartArrow->GetForwardVector() * BulletDistance);
|
||||
FCollisionQueryParams collisionParams;
|
||||
collisionParams.AddIgnoredActor(playerInWorld);
|
||||
collisionParams.AddIgnoredActor(this);
|
||||
/*RecoilVerticalLimit(outHit);*/
|
||||
if (GetWorldTimerManager().IsTimerActive(timerHandle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
|
||||
GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams);
|
||||
//Debug line to see where the trace hit
|
||||
DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, false, 0.2f, 0U, 1);
|
||||
DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, false, 5.0f, 0U, 1.5f);
|
||||
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
|
||||
currentAmmoCount -= 1;
|
||||
UE_LOG(LogTemp, Display, TEXT("Ammo Count: %d"), currentAmmoCount);
|
||||
GenerateRecoilVector();
|
||||
ClickDetectionTimer();
|
||||
bulletCountShoot += 1;
|
||||
bStopShooting = false;
|
||||
if (outHit.bBlockingHit)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Ammo Count: %s"), *outHit.GetActor()->GetName());
|
||||
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
||||
}
|
||||
@ -185,10 +197,10 @@ void ABaseWeaponClass::WeaponScopedFire()
|
||||
{
|
||||
if (endlessVendettaChar->bIsScoped)
|
||||
{
|
||||
recoilMagnitude -= 0.2f;
|
||||
recoilMaxAngleLeft /= 2.f;
|
||||
recoilMaxAngleRight /= 2.f;
|
||||
recoilMinMultiplier -= 0.2f;
|
||||
recoilMagnitude = scopedRecoilMag;
|
||||
recoilMaxAngleLeft = scopedMaxAngleLeft;
|
||||
recoilMaxAngleRight = scopedMaxAngleRight;
|
||||
recoilMinMultiplier = scopedMinMultiplier;
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -24,9 +24,9 @@ protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
void GenerateRecoilVector();
|
||||
|
||||
void ApplyRecoil(float DeltaTime);
|
||||
|
||||
void GenerateRecoilVector();
|
||||
|
||||
void nullSamples();
|
||||
|
||||
@ -44,7 +44,7 @@ protected:
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FName WeaponName;
|
||||
|
||||
@ -54,12 +54,31 @@ public:
|
||||
UPROPERTY(EditAnywhere)
|
||||
float FireRate;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int MagazineSize;
|
||||
|
||||
//how many bullets until the recoil stops going up
|
||||
UPROPERTY(EditAnywhere)
|
||||
int howMnyShotsTillRclStop;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
int currentAmmoCount;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UTexture2D* WeaponImage;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
||||
float scopedRecoilMag;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
||||
float scopedMaxAngleLeft;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
||||
float scopedMaxAngleRight;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
||||
float scopedMinMultiplier;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
virtual void Fire();
|
||||
|
||||
@ -116,6 +135,8 @@ public:
|
||||
FHitResult outHit;
|
||||
FVector traceStart;
|
||||
FVector traceEnd;
|
||||
FVector newTraceEnd;
|
||||
FCollisionQueryParams collisionParams;
|
||||
|
||||
//UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
//void RecoilVerticalLimit(FHitResult Outhit);
|
||||
@ -135,6 +156,6 @@ private:
|
||||
float originalMaxAngleRight;
|
||||
float originalMinMultiplier;
|
||||
|
||||
int currentAmmoCount;
|
||||
|
||||
float currentPitch;
|
||||
bool bStopShooting = false;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user