Added working firerate to weapons & sorted out hold and tap fire
This commit is contained in:
parent
2242379657
commit
93447bde97
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:00e38eda0524fe228dc71f14ef9f96ebec3f8142ffaeca9366f253a7456d529b
|
||||
size 27305
|
||||
oid sha256:059c5de9ae43a57d471949157f8c1e59bcbc14c1ca117627ccb9d1b27036c180
|
||||
size 27098
|
||||
|
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_PickUp_Rifle.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_PickUp_Rifle.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_HoldShoot.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_HoldShoot.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Shoot.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Shoot.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_TapShoot.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_TapShoot.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Weapons.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Weapons.uasset
(Stored with Git LFS)
Binary file not shown.
@ -88,9 +88,7 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
||||
EnhancedInputComponent->BindAction(EquipSecondaryWeapon, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::EquipSecondary);
|
||||
|
||||
//Weapon Shooting
|
||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::TapFireCaller);
|
||||
EnhancedInputComponent->BindAction(HoldShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::HoldFireCaller);
|
||||
//EnhancedInputComponent->BindAction(HoldShootAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::CancelFire);
|
||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::FireCaller);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,34 +193,19 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
||||
}
|
||||
|
||||
//Calls the fire function in the baseWeaponClass
|
||||
void AEndlessVendettaCharacter::TapFireCaller()
|
||||
void AEndlessVendettaCharacter::FireCaller()
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Tap Fire"));
|
||||
if (IsValid(PrimaryWeapon))
|
||||
{
|
||||
PrimaryWeapon->TapFire();
|
||||
PrimaryWeapon->Fire();
|
||||
}
|
||||
if (IsValid(SecondaryWeapon))
|
||||
{
|
||||
SecondaryWeapon->TapFire();
|
||||
SecondaryWeapon->Fire();
|
||||
}
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::HoldFireCaller()
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Hold Fire"));
|
||||
if (IsValid(PrimaryWeapon) || IsValid(SecondaryWeapon))
|
||||
{
|
||||
PrimaryWeapon->HoldFire();
|
||||
}
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::CancelFire()
|
||||
{
|
||||
PrimaryWeapon->CancelFire();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
|
||||
{
|
||||
|
@ -101,12 +101,8 @@ public:
|
||||
ABaseWeaponClass* SecondaryWeapon;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void TapFireCaller();
|
||||
void FireCaller();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void HoldFireCaller();
|
||||
|
||||
void CancelFire();
|
||||
|
||||
protected:
|
||||
/** Called for movement input */
|
||||
|
@ -39,13 +39,7 @@ void ABaseWeaponClass::Tick(float DeltaTime)
|
||||
|
||||
void ABaseWeaponClass::ClickDetectionTimer()
|
||||
{
|
||||
if (GetWorldTimerManager().IsTimerActive(timerHandle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
GetWorldTimerManager().SetTimer(timerHandle, this, &ABaseWeaponClass::TapFire, 1 / FireRate, false);
|
||||
|
||||
|
||||
GetWorldTimerManager().SetTimer(timerHandle, this, &ABaseWeaponClass::Fire, 1 / FireRate, false);
|
||||
}
|
||||
|
||||
void ABaseWeaponClass::CancelFire()
|
||||
@ -53,7 +47,7 @@ void ABaseWeaponClass::CancelFire()
|
||||
GetWorldTimerManager().ClearTimer(timerHandle);
|
||||
}
|
||||
|
||||
void ABaseWeaponClass::TapFire()
|
||||
void ABaseWeaponClass::Fire()
|
||||
{
|
||||
FHitResult outHit;
|
||||
FVector traceStart;
|
||||
@ -63,32 +57,17 @@ void ABaseWeaponClass::TapFire()
|
||||
FCollisionQueryParams collisionParams;
|
||||
collisionParams.AddIgnoredActor(player);
|
||||
collisionParams.AddIgnoredActor(this);
|
||||
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, true, 500.0f, 0U, 5.f);
|
||||
ClickDetectionTimer();
|
||||
if (outHit.bBlockingHit)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("hit item: %s"), *outHit.GetActor()->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
void ABaseWeaponClass::HoldFire()
|
||||
{
|
||||
FHitResult outHit;
|
||||
FVector traceStart;
|
||||
FVector traceEnd;
|
||||
traceStart = GunStartArrow->GetComponentLocation();
|
||||
traceEnd = traceStart + (player->GetActorForwardVector() * BulletDistance);
|
||||
FCollisionQueryParams collisionParams;
|
||||
collisionParams.AddIgnoredActor(player);
|
||||
collisionParams.AddIgnoredActor(this);
|
||||
GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams);
|
||||
|
||||
//Debug line to see where the trace hit
|
||||
DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, true, 500.0f, 0U, 5.f);
|
||||
if (outHit.bBlockingHit)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("hit item: %s"), *outHit.GetActor()->GetName());
|
||||
}
|
||||
}
|
||||
|
@ -43,10 +43,7 @@ public:
|
||||
UTexture2D* WeaponImage;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void TapFire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void HoldFire();
|
||||
void Fire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void ClickDetectionTimer();
|
||||
|
Loading…
Reference in New Issue
Block a user