Update Character for Loaf Crouch

This commit is contained in:
Philip W 2024-01-27 14:20:46 +00:00
parent d1b19e6f71
commit 9fc962cd77
9 changed files with 44 additions and 7 deletions

BIN
SeagullGame/Content/John/BP_John.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
SeagullGame/Content/TopDown/Blueprints/edwin_loaf.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

View File

@ -156,6 +156,22 @@ void ASeagullGameCharacter::EndGame()
OnGameEnd.Broadcast("You Win!");
}
void ASeagullGameCharacter::CrouchActionPressed(const FInputActionValue& Value)
{
GetMesh()->SetVisibility(false);
TArray<UActorComponent*> ActorComponents = GetComponentsByTag(UStaticMeshComponent::StaticClass(), "Loaf");
UStaticMeshComponent* StaticMeshComponent = Cast<UStaticMeshComponent>(ActorComponents[0]);
StaticMeshComponent->SetVisibility(true);
}
void ASeagullGameCharacter::CrouchActionUnPressed(const FInputActionValue& Value)
{
GetMesh()->SetVisibility(true);
TArray<UActorComponent*> ActorComponents = GetComponentsByTag(UStaticMeshComponent::StaticClass(), "Loaf");
UStaticMeshComponent* StaticMeshComponent = Cast<UStaticMeshComponent>(ActorComponents[0]);
StaticMeshComponent->SetVisibility(false);
}
void ASeagullGameCharacter::PickupItem()
{
OnPlayerPickupItem.Broadcast();
@ -229,6 +245,10 @@ void ASeagullGameCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInp
//Pickup
EnhancedInputComponent->BindAction(PickupAction, ETriggerEvent::Started, this, &ASeagullGameCharacter::PickupItem);
//Crouch
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this, &ASeagullGameCharacter::CrouchActionPressed);
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &ASeagullGameCharacter::CrouchActionUnPressed);
}
}

View File

@ -53,6 +53,10 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* PickupAction;
/** Crouch Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* CrouchAction;
/** Move Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* MoveAction;
@ -85,6 +89,10 @@ public:
float GameTime = 120;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "General")
float Score = 0;
UFUNCTION(Category = "General")
void CrouchActionPressed(const FInputActionValue& Value);
UFUNCTION(Category = "General")
void CrouchActionUnPressed(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "Item")
void PickupItem();