Update Character for Zooming In and Out via Scroll

This commit is contained in:
Philip W 2024-01-27 15:10:34 +00:00
parent e8edfaf51d
commit c8b3fb37c0
6 changed files with 31 additions and 5 deletions

Binary file not shown.

BIN
SeagullGame/Content/TopDown/Input/Actions/IAS_Scroll.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -172,6 +172,20 @@ void ASeagullGameCharacter::CrouchActionUnPressed(const FInputActionValue& Value
StaticMeshComponent->SetVisibility(false);
}
void ASeagullGameCharacter::Scroll(const FInputActionValue& Value)
{
float ScrollAmount = Value.Get<float>() * -1;
CameraBoom->TargetArmLength += ScrollAmount * 100;
if (CameraBoom->TargetArmLength < 300)
{
CameraBoom->TargetArmLength = 300;
}
if (CameraBoom->TargetArmLength > 1400)
{
CameraBoom->TargetArmLength = 1400;
}
}
void ASeagullGameCharacter::PickupItem()
{
OnPlayerPickupItem.Broadcast();
@ -249,6 +263,9 @@ void ASeagullGameCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInp
//Crouch
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this, &ASeagullGameCharacter::CrouchActionPressed);
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &ASeagullGameCharacter::CrouchActionUnPressed);
//Scroll
EnhancedInputComponent->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ASeagullGameCharacter::Scroll);
}
}

View File

@ -65,6 +65,10 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* LookAction;
/** Scroll Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* ScrollAction;
virtual void BeginPlay() override;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Health")
@ -93,6 +97,8 @@ public:
void CrouchActionPressed(const FInputActionValue& Value);
UFUNCTION(Category = "General")
void CrouchActionUnPressed(const FInputActionValue& Value);
UFUNCTION(Category = "General")
void Scroll(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "Item")
void PickupItem();