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;
|
bIsHoldingGun = true;
|
||||||
|
|
||||||
|
HoldingGunClass = gunItem->GetClass();
|
||||||
|
|
||||||
MaxRange = gunItem->MaxRange;
|
MaxRange = gunItem->MaxRange;
|
||||||
DamageValue = gunItem->DamageValue;
|
DamageValue = gunItem->DamageValue;
|
||||||
FireRateCooldown = gunItem->FireRateCooldown;
|
FireRateCooldown = gunItem->FireRateCooldown;
|
||||||
|
|
@ -101,9 +103,27 @@ void UShootingComponent::DropGun()
|
||||||
{
|
{
|
||||||
if (!bIsHoldingGun) return;
|
if (!bIsHoldingGun) return;
|
||||||
|
|
||||||
// TODO: Spawn gun actor
|
FVector ForwardVector = PlayerCharacter->GetActorForwardVector();
|
||||||
|
FVector PlayerPos = PlayerCharacter->GetActorLocation();
|
||||||
|
FVector DroppedGunPos = PlayerPos + (ForwardVector * DropGunRange);
|
||||||
|
|
||||||
|
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;
|
bIsHoldingGun = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UShootingComponent::ResetFireCooldown()
|
void UShootingComponent::ResetFireCooldown()
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ void AExoPlayerController::SetupInputComponent()
|
||||||
EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerAim);
|
EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerAim);
|
||||||
EnhancedInputComponent->BindAction(MeleAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerMeleAttack);
|
EnhancedInputComponent->BindAction(MeleAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerMeleAttack);
|
||||||
EnhancedInputComponent->BindAction(ChangeWeaponAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerChangeWeapon);
|
EnhancedInputComponent->BindAction(ChangeWeaponAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerChangeWeapon);
|
||||||
|
EnhancedInputComponent->BindAction(DropWeaponAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerDropWeapon);
|
||||||
EnhancedInputComponent->BindAction(ReloadAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerReload);
|
EnhancedInputComponent->BindAction(ReloadAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,6 +171,11 @@ void AExoPlayerController::PlayerChangeWeapon()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AExoPlayerController::PlayerDropWeapon()
|
||||||
|
{
|
||||||
|
ShootingComponent->DropGun();
|
||||||
|
}
|
||||||
|
|
||||||
void AExoPlayerController::PlayerReload()
|
void AExoPlayerController::PlayerReload()
|
||||||
{
|
{
|
||||||
ShootingComponent->Reload();
|
ShootingComponent->Reload();
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ public:
|
||||||
UFUNCTION(Category = "Shooting")
|
UFUNCTION(Category = "Shooting")
|
||||||
void DropGun();
|
void DropGun();
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shooting")
|
||||||
|
float DropGunRange = 20.0f;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ResetFireCooldown();
|
void ResetFireCooldown();
|
||||||
|
|
||||||
|
|
@ -55,6 +58,7 @@ private:
|
||||||
FTimerHandle ReloadTimer;
|
FTimerHandle ReloadTimer;
|
||||||
|
|
||||||
bool bIsHoldingGun = false;
|
bool bIsHoldingGun = false;
|
||||||
|
TSubclassOf<AActor> HoldingGunClass;
|
||||||
|
|
||||||
bool bCanShoot = true;
|
bool bCanShoot = true;
|
||||||
bool bIsReloading = false;
|
bool bIsReloading = false;
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void SetupInputComponent() override;
|
virtual void SetupInputComponent() override;
|
||||||
|
|
||||||
// Moja propozycja sterowania po prawej [Hubert]
|
// Po prawej przypisane aktualnie klawisze
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void Move(const FInputActionValue& InputActionValue); //WSAD
|
void Move(const FInputActionValue& InputActionValue); // WSAD
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void Look(const FInputActionValue& InputActionValue); // MouseXY
|
void Look(const FInputActionValue& InputActionValue); // MouseXY
|
||||||
|
|
@ -42,7 +42,7 @@ protected:
|
||||||
void PlayerJump(); // Space
|
void PlayerJump(); // Space
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void PlayerDodge(); // LShift(Pressed)
|
void PlayerDodge(); // Left Alt
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void ResetDodge();
|
void ResetDodge();
|
||||||
|
|
@ -63,13 +63,16 @@ protected:
|
||||||
void PlayerShoot(); // LPM
|
void PlayerShoot(); // LPM
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void PlayerAim(); // PPM
|
void PlayerAim(); // PPM - nieprzypisane
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void PlayerMeleAttack(); // V
|
void PlayerMeleAttack(); // V - nieprzypisane
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
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")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void PlayerReload(); // R
|
void PlayerReload(); // R
|
||||||
|
|
@ -121,6 +124,9 @@ protected:
|
||||||
UPROPERTY(EditAnywhere, Category = "Input")
|
UPROPERTY(EditAnywhere, Category = "Input")
|
||||||
TObjectPtr<UInputAction> ChangeWeaponAction;
|
TObjectPtr<UInputAction> ChangeWeaponAction;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Input")
|
||||||
|
TObjectPtr<UInputAction> DropWeaponAction;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
|
||||||
TObjectPtr<AExoPlayerCharacter> PlayerCharacter;
|
TObjectPtr<AExoPlayerCharacter> PlayerCharacter;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user