diff --git a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset index aa2df4f..b9e9b35 100644 Binary files a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset and b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset differ diff --git a/Content/Blueprints/Items/RevolverGun.uasset b/Content/Blueprints/Items/RevolverGun.uasset index 0230aa1..4549f1f 100644 Binary files a/Content/Blueprints/Items/RevolverGun.uasset and b/Content/Blueprints/Items/RevolverGun.uasset differ diff --git a/Content/Blueprints/Items/ShotGun.uasset b/Content/Blueprints/Items/ShotGun.uasset index a33f65d..7a5fef4 100644 Binary files a/Content/Blueprints/Items/ShotGun.uasset and b/Content/Blueprints/Items/ShotGun.uasset differ diff --git a/Content/Blueprints/Player/BP_ExoPlayerController.uasset b/Content/Blueprints/Player/BP_ExoPlayerController.uasset index b7980c0..2913100 100644 Binary files a/Content/Blueprints/Player/BP_ExoPlayerController.uasset and b/Content/Blueprints/Player/BP_ExoPlayerController.uasset differ diff --git a/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset b/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset index b6733f8..a0f74ec 100644 Binary files a/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset and b/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset differ diff --git a/Content/Blueprints/Player/Inputs/Inputs/AI_DropWeapon.uasset b/Content/Blueprints/Player/Inputs/Inputs/AI_DropWeapon.uasset new file mode 100644 index 0000000..0fab725 Binary files /dev/null and b/Content/Blueprints/Player/Inputs/Inputs/AI_DropWeapon.uasset differ diff --git a/Content/Levels/TestMap.umap b/Content/Levels/TestMap.umap index 7c6bb0e..2c652fb 100644 Binary files a/Content/Levels/TestMap.umap and b/Content/Levels/TestMap.umap differ diff --git a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp index 1166109..8b850c3 100644 --- a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp +++ b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp @@ -87,6 +87,8 @@ void UShootingComponent::PickUpGun(AGunBase* gunItem) DropGun(); bIsHoldingGun = true; + + HoldingGunClass = gunItem->GetClass(); MaxRange = gunItem->MaxRange; DamageValue = gunItem->DamageValue; @@ -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); + + FTransform DroppedGunTransform = PlayerCharacter->GetActorTransform(); + DroppedGunTransform.SetLocation(DroppedGunPos); - bIsHoldingGun = false; + AGunBase* DroppedGun = GetWorld()->SpawnActor(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() diff --git a/Source/Exo/Private/Player/ExoPlayerController.cpp b/Source/Exo/Private/Player/ExoPlayerController.cpp index 3f2c651..1f783ba 100644 --- a/Source/Exo/Private/Player/ExoPlayerController.cpp +++ b/Source/Exo/Private/Player/ExoPlayerController.cpp @@ -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(); diff --git a/Source/Exo/Public/Characters/Components/ShootingComponent.h b/Source/Exo/Public/Characters/Components/ShootingComponent.h index 7239898..2912092 100644 --- a/Source/Exo/Public/Characters/Components/ShootingComponent.h +++ b/Source/Exo/Public/Characters/Components/ShootingComponent.h @@ -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 HoldingGunClass; bool bCanShoot = true; bool bIsReloading = false; diff --git a/Source/Exo/Public/Player/ExoPlayerController.h b/Source/Exo/Public/Player/ExoPlayerController.h index 6a7053e..befa154 100644 --- a/Source/Exo/Public/Player/ExoPlayerController.h +++ b/Source/Exo/Public/Player/ExoPlayerController.h @@ -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 @@ -120,6 +123,9 @@ protected: UPROPERTY(EditAnywhere, Category = "Input") TObjectPtr ChangeWeaponAction; + + UPROPERTY(EditAnywhere, Category = "Input") + TObjectPtr DropWeaponAction; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character") TObjectPtr PlayerCharacter;