Added Basic weapon scope in functionality
This commit is contained in:
parent
fed628ed77
commit
2c29972810
@ -6,3 +6,6 @@ bAllowClassAndBlueprintPinMatching=true
|
|||||||
bReplaceBlueprintWithClass= true
|
bReplaceBlueprintWithClass= true
|
||||||
bDontLoadBlueprintOutsideEditor= true
|
bDontLoadBlueprintOutsideEditor= true
|
||||||
bBlueprintIsNotBlueprintType= 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
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:a64df34489d5d5452a5b7310e944fd0cb2ea1a2a52eacf2c7bcf9a8d03aadb2c
|
oid sha256:ff90caf01f6ea20dccd612ea5629215ce5c5a4a63e4da2ec242cabf9000bd6c6
|
||||||
size 40999
|
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
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:639f363d6702f2597b9140becc6854a1a5e5872978e79c4a83b062ccec7c1966
|
oid sha256:6a0af94b654f58c85c8b4453fa211608ecc7bc67b9c82e2e3768814e906babcd
|
||||||
size 15739
|
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
|
//Weapon Shooting
|
||||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::FireCaller);
|
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);
|
AActor* SecondaryWeaponActor = GetWorld()->SpawnActor<AActor>(SecondaryWeaponClass, spawnParams);
|
||||||
SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
|
SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
|
||||||
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
|
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calls the fire function in the baseWeaponClass
|
//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)
|
void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ class AEndlessVendettaCharacter : public ACharacter
|
|||||||
class UInputAction* TapShootAction;
|
class UInputAction* TapShootAction;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
||||||
class UInputAction* HoldShootAction;
|
class UInputAction* GunAimInAction;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AEndlessVendettaCharacter();
|
AEndlessVendettaCharacter();
|
||||||
@ -103,6 +103,13 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
void FireCaller();
|
void FireCaller();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
|
void GunRightClick();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
|
void StopGunRightClick();
|
||||||
|
|
||||||
|
UArrowComponent* ScopedLocationArrow;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Called for movement input */
|
/** Called for movement input */
|
||||||
|
@ -52,9 +52,7 @@ void ABaseWeaponClass::Tick(float DeltaTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Recoil Handling ////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Recoil Handling //
|
|
||||||
void ABaseWeaponClass::GenerateRecoilVector()
|
void ABaseWeaponClass::GenerateRecoilVector()
|
||||||
{
|
{
|
||||||
float angle = FMath::RandRange(recoilMaxAngleLeft, -recoilMaxAngleRight); //randomg recoil vector angle between left and right
|
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;
|
recoilCurvet = Time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fire handling //////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Fire handling //
|
|
||||||
void ABaseWeaponClass::ClickDetectionTimer()
|
void ABaseWeaponClass::ClickDetectionTimer()
|
||||||
{
|
{
|
||||||
GetWorldTimerManager().SetTimer(timerHandle, this, &ABaseWeaponClass::Fire, 1 / FireRate, false);
|
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")
|
UFUNCTION(BlueprintCallable, Category = "Recoil")
|
||||||
void UpdateSamples(float Amp, float Time);
|
void UpdateSamples(float Amp, float Time);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
|
void WeaponScopedFire();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user