Added Weapon Aiming for all primary and secondary weapons

This commit is contained in:
MH261677 2024-01-22 17:10:53 +00:00
parent 701e42bcf5
commit 81a3fe895f
10 changed files with 35 additions and 32 deletions

View File

@ -491,29 +491,17 @@ void AEndlessVendettaCharacter::GunRightClick()
{
if (IsValid(PrimaryWeapon) && !bIsScoped)
{
for (UActorComponent* actorComp : this->GetComponentsByTag(UArrowComponent::StaticClass(), FName("ScopedLocationArrow")))
{
ScopedLocationArrow = Cast<UArrowComponent>(actorComp);
break;
}
if (!IsValid(ScopedLocationArrow)) return;
PrimaryWeapon->SetActorLocation(ScopedLocationArrow->GetComponentLocation());
bIsScoped = true;
PrimaryWeapon->WeaponScopedFire();
this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
StartPrimaryWeaponADS();
//this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
}
if (IsValid(SecondaryWeapon) && !bIsScoped)
{
for (UActorComponent* actorComp : this->GetComponentsByTag(UArrowComponent::StaticClass(), FName("ScopedLocationArrow")))
{
ScopedLocationArrow = Cast<UArrowComponent>(actorComp);
break;
}
if (!IsValid(ScopedLocationArrow)) return;
bIsScoped = true;
SecondaryWeapon->WeaponScopedFire();
SecondaryWeapon->SetActorLocation(ScopedLocationArrow->GetComponentLocation());
this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
StartSecondaryWeaponADS();
//this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
}
}
@ -523,15 +511,15 @@ void AEndlessVendettaCharacter::StopGunRightClick()
{
bIsScoped = false;
PrimaryWeapon->WeaponScopedFire();
PrimaryWeapon->SetActorRelativeLocation(FVector(0, 0, 0));
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
StopPrimaryWeaponADS();
//this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
}
if (IsValid(SecondaryWeapon))
{
bIsScoped = false;
SecondaryWeapon->WeaponScopedFire();
SecondaryWeapon->SetActorRelativeLocation(FVector(0, 0, 0));
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
StopSecondaryWeaponADS();
//this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
}
}

View File

@ -118,6 +118,15 @@ public:
bool bIsSecondaryWeaponCreated = false;
bool bIsWeaponPickedUp = false;
UFUNCTION(BlueprintImplementableEvent)
void StartPrimaryWeaponADS();
UFUNCTION(BlueprintImplementableEvent)
void StopPrimaryWeaponADS();
UFUNCTION(BlueprintImplementableEvent)
void StartSecondaryWeaponADS();
UFUNCTION(BlueprintImplementableEvent)
void StopSecondaryWeaponADS();
protected:
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;