feat: add swapping and drop weapons
Added swapping current weapon with weapon from ground. Added dropping weapon.
This commit is contained in:
parent
f666cd7d45
commit
1beaad73bc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_DropWeapon.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_DropWeapon.uasset
Normal file
Binary file not shown.
Binary file not shown.
|
|
@ -88,6 +88,8 @@ void UShootingComponent::PickUpGun(AGunBase* gunItem)
|
|||
|
||||
bIsHoldingGun = true;
|
||||
|
||||
HoldingGunClass = gunItem->GetClass();
|
||||
|
||||
MaxRange = gunItem->MaxRange;
|
||||
DamageValue = gunItem->DamageValue;
|
||||
FireRateCooldown = gunItem->FireRateCooldown;
|
||||
|
|
@ -101,9 +103,27 @@ void UShootingComponent::DropGun()
|
|||
{
|
||||
if (!bIsHoldingGun) return;
|
||||
|
||||
// TODO: Spawn gun actor
|
||||
FVector ForwardVector = PlayerCharacter->GetActorForwardVector();
|
||||
FVector PlayerPos = PlayerCharacter->GetActorLocation();
|
||||
FVector DroppedGunPos = PlayerPos + (ForwardVector * DropGunRange);
|
||||
|
||||
bIsHoldingGun = false;
|
||||
FTransform DroppedGunTransform = PlayerCharacter->GetActorTransform();
|
||||
DroppedGunTransform.SetLocation(DroppedGunPos);
|
||||
|
||||
AGunBase* DroppedGun = GetWorld()->SpawnActor<AGunBase>(HoldingGunClass, DroppedGunTransform);
|
||||
|
||||
if (DroppedGun)
|
||||
{
|
||||
DroppedGun->MaxRange = MaxRange;
|
||||
DroppedGun->DamageValue = DamageValue;
|
||||
DroppedGun->FireRateCooldown = FireRateCooldown;
|
||||
DroppedGun->RecoilForceMultiplier = RecoilForceMultiplier;
|
||||
DroppedGun->ReloadTime = ReloadTime;
|
||||
DroppedGun->CurrentAmmo = CurrentAmmo;
|
||||
DroppedGun->MaxAmmo = MaxAmmo;
|
||||
|
||||
bIsHoldingGun = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UShootingComponent::ResetFireCooldown()
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ void AExoPlayerController::SetupInputComponent()
|
|||
EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerAim);
|
||||
EnhancedInputComponent->BindAction(MeleAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerMeleAttack);
|
||||
EnhancedInputComponent->BindAction(ChangeWeaponAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerChangeWeapon);
|
||||
EnhancedInputComponent->BindAction(DropWeaponAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerDropWeapon);
|
||||
EnhancedInputComponent->BindAction(ReloadAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerReload);
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +171,11 @@ void AExoPlayerController::PlayerChangeWeapon()
|
|||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerDropWeapon()
|
||||
{
|
||||
ShootingComponent->DropGun();
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerReload()
|
||||
{
|
||||
ShootingComponent->Reload();
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ public:
|
|||
UFUNCTION(Category = "Shooting")
|
||||
void DropGun();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shooting")
|
||||
float DropGunRange = 20.0f;
|
||||
|
||||
private:
|
||||
void ResetFireCooldown();
|
||||
|
||||
|
|
@ -55,6 +58,7 @@ private:
|
|||
FTimerHandle ReloadTimer;
|
||||
|
||||
bool bIsHoldingGun = false;
|
||||
TSubclassOf<AActor> HoldingGunClass;
|
||||
|
||||
bool bCanShoot = true;
|
||||
bool bIsReloading = false;
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ public:
|
|||
protected:
|
||||
virtual void SetupInputComponent() override;
|
||||
|
||||
// Moja propozycja sterowania po prawej [Hubert]
|
||||
// Po prawej przypisane aktualnie klawisze
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void Move(const FInputActionValue& InputActionValue); //WSAD
|
||||
void Move(const FInputActionValue& InputActionValue); // WSAD
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void Look(const FInputActionValue& InputActionValue); // MouseXY
|
||||
|
|
@ -42,7 +42,7 @@ protected:
|
|||
void PlayerJump(); // Space
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerDodge(); // LShift(Pressed)
|
||||
void PlayerDodge(); // Left Alt
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void ResetDodge();
|
||||
|
|
@ -63,13 +63,16 @@ protected:
|
|||
void PlayerShoot(); // LPM
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerAim(); // PPM
|
||||
void PlayerAim(); // PPM - nieprzypisane
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerMeleAttack(); // V
|
||||
void PlayerMeleAttack(); // V - nieprzypisane
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerChangeWeapon(); // 1\2\MouseScroll
|
||||
void PlayerChangeWeapon(); // 1\2\MouseScroll - nieprzypisane
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerDropWeapon(); // F
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerReload(); // R
|
||||
|
|
@ -121,6 +124,9 @@ protected:
|
|||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> ChangeWeaponAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> DropWeaponAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
|
||||
TObjectPtr<AExoPlayerCharacter> PlayerCharacter;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user