Modified recoil limits
This commit is contained in:
parent
8f71d77945
commit
be4ea78ab4
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
@ -92,6 +92,7 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
||||
|
||||
//Weapon Shooting
|
||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::FireCaller);
|
||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopFire);
|
||||
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::GunRightClick);
|
||||
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopGunRightClick);
|
||||
|
||||
@ -229,7 +230,6 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
||||
//Calls the fire function in the baseWeaponClass
|
||||
void AEndlessVendettaCharacter::FireCaller()
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Tap Fire"));
|
||||
if (IsValid(PrimaryWeapon))
|
||||
{
|
||||
PrimaryWeapon->Fire();
|
||||
@ -240,6 +240,18 @@ void AEndlessVendettaCharacter::FireCaller()
|
||||
}
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::StopFire()
|
||||
{
|
||||
if (IsValid(PrimaryWeapon))
|
||||
{
|
||||
PrimaryWeapon->CancelFire();
|
||||
}
|
||||
if (IsValid(SecondaryWeapon))
|
||||
{
|
||||
SecondaryWeapon->CancelFire();
|
||||
}
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::GunRightClick()
|
||||
{
|
||||
if (IsValid(PrimaryWeapon) && !bIsScoped)
|
||||
|
@ -123,6 +123,9 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void GunReload();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void StopFire();
|
||||
|
||||
UArrowComponent* ScopedLocationArrow;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Dont Touch")
|
||||
|
@ -85,12 +85,26 @@ void ABaseWeaponClass::ApplyRecoil(float DeltaTime)
|
||||
{
|
||||
float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time
|
||||
recoilTime += DeltaTime;
|
||||
playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime));
|
||||
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);
|
||||
playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime));
|
||||
UE_LOG(LogTemp, Warning, TEXT("recoilTime: %f"), recoilTime);
|
||||
UpdateSamples(amplitude, recoilTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//void ABaseWeaponClass::RecoilVerticalLimit(FHitResult Outhit)
|
||||
//{
|
||||
// double currentCameraRot = playerInWorld->GetControlRotation().Pitch;
|
||||
// if (bulletCountShoot >= 3)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
void ABaseWeaponClass::nullSamples()
|
||||
{
|
||||
recoilCurvet = 0;
|
||||
@ -133,6 +147,8 @@ void ABaseWeaponClass::ClickDetectionTimer()
|
||||
void ABaseWeaponClass::CancelFire()
|
||||
{
|
||||
GetWorldTimerManager().ClearTimer(timerHandle);
|
||||
UE_LOG(LogTemp, Display, TEXT("FireCancelled"));
|
||||
bulletCountShoot = 0;
|
||||
}
|
||||
|
||||
void ABaseWeaponClass::Fire()
|
||||
@ -140,14 +156,12 @@ void ABaseWeaponClass::Fire()
|
||||
if(currentAmmoCount > 0)
|
||||
{
|
||||
//do damage fallof based off distance
|
||||
FHitResult outHit;
|
||||
FVector traceStart;
|
||||
FVector traceEnd;
|
||||
traceStart = GunStartArrow->GetComponentLocation();
|
||||
traceEnd = traceStart + (GunStartArrow->GetForwardVector() * BulletDistance);
|
||||
FCollisionQueryParams collisionParams;
|
||||
collisionParams.AddIgnoredActor(playerInWorld);
|
||||
collisionParams.AddIgnoredActor(this);
|
||||
/*RecoilVerticalLimit(outHit);*/
|
||||
if (GetWorldTimerManager().IsTimerActive(timerHandle))
|
||||
{
|
||||
return;
|
||||
@ -160,9 +174,10 @@ void ABaseWeaponClass::Fire()
|
||||
UE_LOG(LogTemp, Display, TEXT("Ammo Count: %d"), currentAmmoCount);
|
||||
GenerateRecoilVector();
|
||||
ClickDetectionTimer();
|
||||
bulletCountShoot += 1;
|
||||
if (outHit.bBlockingHit)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("hit item: %s"), *outHit.GetActor()->GetName());
|
||||
//UE_LOG(LogTemp, Display, TEXT("hit item: %s"), *outHit.GetActor()->GetName());
|
||||
}
|
||||
}
|
||||
else if(currentAmmoCount <= 0)
|
||||
|
@ -113,6 +113,16 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void WeaponReload();
|
||||
|
||||
FHitResult outHit;
|
||||
FVector traceStart;
|
||||
FVector traceEnd;
|
||||
|
||||
//UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
//void RecoilVerticalLimit(FHitResult Outhit);
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
int bulletCountShoot; //Gets how many bullets shot per
|
||||
|
||||
private:
|
||||
|
||||
UArrowComponent* GunStartArrow;
|
||||
|
Loading…
Reference in New Issue
Block a user