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
|
//Weapon Shooting
|
||||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::FireCaller);
|
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::Triggered, this, &AEndlessVendettaCharacter::GunRightClick);
|
||||||
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopGunRightClick);
|
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopGunRightClick);
|
||||||
|
|
||||||
@ -229,7 +230,6 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
|||||||
//Calls the fire function in the baseWeaponClass
|
//Calls the fire function in the baseWeaponClass
|
||||||
void AEndlessVendettaCharacter::FireCaller()
|
void AEndlessVendettaCharacter::FireCaller()
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Tap Fire"));
|
|
||||||
if (IsValid(PrimaryWeapon))
|
if (IsValid(PrimaryWeapon))
|
||||||
{
|
{
|
||||||
PrimaryWeapon->Fire();
|
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()
|
void AEndlessVendettaCharacter::GunRightClick()
|
||||||
{
|
{
|
||||||
if (IsValid(PrimaryWeapon) && !bIsScoped)
|
if (IsValid(PrimaryWeapon) && !bIsScoped)
|
||||||
|
@ -123,6 +123,9 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
void GunReload();
|
void GunReload();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
|
void StopFire();
|
||||||
|
|
||||||
UArrowComponent* ScopedLocationArrow;
|
UArrowComponent* ScopedLocationArrow;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Dont Touch")
|
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
|
float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time
|
||||||
recoilTime += DeltaTime;
|
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));
|
playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime));
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("recoilTime: %f"), recoilTime);
|
||||||
UpdateSamples(amplitude, recoilTime);
|
UpdateSamples(amplitude, recoilTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//void ABaseWeaponClass::RecoilVerticalLimit(FHitResult Outhit)
|
||||||
|
//{
|
||||||
|
// double currentCameraRot = playerInWorld->GetControlRotation().Pitch;
|
||||||
|
// if (bulletCountShoot >= 3)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
void ABaseWeaponClass::nullSamples()
|
void ABaseWeaponClass::nullSamples()
|
||||||
{
|
{
|
||||||
recoilCurvet = 0;
|
recoilCurvet = 0;
|
||||||
@ -133,6 +147,8 @@ void ABaseWeaponClass::ClickDetectionTimer()
|
|||||||
void ABaseWeaponClass::CancelFire()
|
void ABaseWeaponClass::CancelFire()
|
||||||
{
|
{
|
||||||
GetWorldTimerManager().ClearTimer(timerHandle);
|
GetWorldTimerManager().ClearTimer(timerHandle);
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("FireCancelled"));
|
||||||
|
bulletCountShoot = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABaseWeaponClass::Fire()
|
void ABaseWeaponClass::Fire()
|
||||||
@ -140,14 +156,12 @@ void ABaseWeaponClass::Fire()
|
|||||||
if(currentAmmoCount > 0)
|
if(currentAmmoCount > 0)
|
||||||
{
|
{
|
||||||
//do damage fallof based off distance
|
//do damage fallof based off distance
|
||||||
FHitResult outHit;
|
|
||||||
FVector traceStart;
|
|
||||||
FVector traceEnd;
|
|
||||||
traceStart = GunStartArrow->GetComponentLocation();
|
traceStart = GunStartArrow->GetComponentLocation();
|
||||||
traceEnd = traceStart + (GunStartArrow->GetForwardVector() * BulletDistance);
|
traceEnd = traceStart + (GunStartArrow->GetForwardVector() * BulletDistance);
|
||||||
FCollisionQueryParams collisionParams;
|
FCollisionQueryParams collisionParams;
|
||||||
collisionParams.AddIgnoredActor(playerInWorld);
|
collisionParams.AddIgnoredActor(playerInWorld);
|
||||||
collisionParams.AddIgnoredActor(this);
|
collisionParams.AddIgnoredActor(this);
|
||||||
|
/*RecoilVerticalLimit(outHit);*/
|
||||||
if (GetWorldTimerManager().IsTimerActive(timerHandle))
|
if (GetWorldTimerManager().IsTimerActive(timerHandle))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -160,9 +174,10 @@ void ABaseWeaponClass::Fire()
|
|||||||
UE_LOG(LogTemp, Display, TEXT("Ammo Count: %d"), currentAmmoCount);
|
UE_LOG(LogTemp, Display, TEXT("Ammo Count: %d"), currentAmmoCount);
|
||||||
GenerateRecoilVector();
|
GenerateRecoilVector();
|
||||||
ClickDetectionTimer();
|
ClickDetectionTimer();
|
||||||
|
bulletCountShoot += 1;
|
||||||
if (outHit.bBlockingHit)
|
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)
|
else if(currentAmmoCount <= 0)
|
||||||
|
@ -113,6 +113,16 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
void WeaponReload();
|
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:
|
private:
|
||||||
|
|
||||||
UArrowComponent* GunStartArrow;
|
UArrowComponent* GunStartArrow;
|
||||||
|
Loading…
Reference in New Issue
Block a user