Added Basic weapon scope in functionality
This commit is contained in:
parent
fed628ed77
commit
2c29972810
@ -6,3 +6,6 @@ bAllowClassAndBlueprintPinMatching=true
|
||||
bReplaceBlueprintWithClass= true
|
||||
bDontLoadBlueprintOutsideEditor= true
|
||||
bBlueprintIsNotBlueprintType= true
|
||||
|
||||
[/Script/AdvancedPreviewScene.SharedProfiles]
|
||||
|
||||
|
BIN
EndlessVendetta/Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a64df34489d5d5452a5b7310e944fd0cb2ea1a2a52eacf2c7bcf9a8d03aadb2c
|
||||
size 40999
|
||||
oid sha256:ff90caf01f6ea20dccd612ea5629215ce5c5a4a63e4da2ec242cabf9000bd6c6
|
||||
size 42353
|
||||
|
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.
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:75503df8d15af2a4661c6cd18bc8f690d50f79cafe5ea8e2b3665db0b882cc24
|
||||
size 1370
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:639f363d6702f2597b9140becc6854a1a5e5872978e79c4a83b062ccec7c1966
|
||||
size 15739
|
||||
oid sha256:6a0af94b654f58c85c8b4453fa211608ecc7bc67b9c82e2e3768814e906babcd
|
||||
size 16334
|
||||
|
BIN
EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1beca35b5b67f492442adf27a1933f51133cce10ed01c3ae69b21a371efe6c4e
|
||||
size 5061
|
@ -89,6 +89,8 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
||||
|
||||
//Weapon Shooting
|
||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::FireCaller);
|
||||
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::GunRightClick);
|
||||
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopGunRightClick);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,8 +190,6 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
||||
AActor* SecondaryWeaponActor = GetWorld()->SpawnActor<AActor>(SecondaryWeaponClass, spawnParams);
|
||||
SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
|
||||
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Calls the fire function in the baseWeaponClass
|
||||
@ -206,6 +206,42 @@ void AEndlessVendettaCharacter::FireCaller()
|
||||
}
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::GunRightClick()
|
||||
{
|
||||
if (IsValid(PrimaryWeapon))
|
||||
{
|
||||
for (UActorComponent* actorComp : this->GetComponentsByTag(UArrowComponent::StaticClass(), FName("ScopedLocationArrow")))
|
||||
{
|
||||
ScopedLocationArrow = Cast<UArrowComponent>(actorComp);
|
||||
break;
|
||||
}
|
||||
if (!IsValid(ScopedLocationArrow)) return;
|
||||
PrimaryWeapon->SetActorLocation(ScopedLocationArrow->GetComponentLocation());
|
||||
PrimaryWeapon->WeaponScopedFire();
|
||||
this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
|
||||
}
|
||||
if (IsValid(SecondaryWeapon))
|
||||
{
|
||||
SecondaryWeapon->WeaponScopedFire();
|
||||
SecondaryWeapon->SetActorLocation(ScopedLocationArrow->GetComponentLocation());
|
||||
this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
|
||||
}
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::StopGunRightClick()
|
||||
{
|
||||
if (IsValid(PrimaryWeapon))
|
||||
{
|
||||
PrimaryWeapon->SetActorRelativeLocation(FVector(0,0,0));
|
||||
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
|
||||
}
|
||||
if (IsValid(SecondaryWeapon))
|
||||
{
|
||||
SecondaryWeapon->SetActorRelativeLocation(FVector(0,0,0));
|
||||
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ class AEndlessVendettaCharacter : public ACharacter
|
||||
class UInputAction* TapShootAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
||||
class UInputAction* HoldShootAction;
|
||||
class UInputAction* GunAimInAction;
|
||||
|
||||
public:
|
||||
AEndlessVendettaCharacter();
|
||||
@ -103,6 +103,13 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void FireCaller();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void GunRightClick();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void StopGunRightClick();
|
||||
|
||||
UArrowComponent* ScopedLocationArrow;
|
||||
|
||||
protected:
|
||||
/** Called for movement input */
|
||||
|
@ -52,9 +52,7 @@ void ABaseWeaponClass::Tick(float DeltaTime)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Recoil Handling //
|
||||
// Recoil Handling ////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void ABaseWeaponClass::GenerateRecoilVector()
|
||||
{
|
||||
float angle = FMath::RandRange(recoilMaxAngleLeft, -recoilMaxAngleRight); //randomg recoil vector angle between left and right
|
||||
@ -117,8 +115,7 @@ void ABaseWeaponClass::UpdateSamples(float Amp, float Time)
|
||||
recoilCurvet = Time;
|
||||
}
|
||||
|
||||
|
||||
// Fire handling //
|
||||
// Fire handling //////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void ABaseWeaponClass::ClickDetectionTimer()
|
||||
{
|
||||
GetWorldTimerManager().SetTimer(timerHandle, this, &ABaseWeaponClass::Fire, 1 / FireRate, false);
|
||||
@ -156,3 +153,13 @@ void ABaseWeaponClass::Fire()
|
||||
}
|
||||
}
|
||||
|
||||
void ABaseWeaponClass::WeaponScopedFire()
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Activated WeaponScopedFire function in BaseWeaponClass"));
|
||||
recoilMagnitude -= 0.2f;
|
||||
recoilMaxAngleLeft /= 2.f;
|
||||
recoilMaxAngleRight /= 2.f;
|
||||
recoilMinMultiplier -= 2.f;
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,7 +106,8 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Recoil")
|
||||
void UpdateSamples(float Amp, float Time);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void WeaponScopedFire();
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user