Compare commits
	
		
			2 Commits
		
	
	
		
			4e99898af9
			...
			a25f08b832
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a25f08b832 | |||
| 2320014f72 | 
							
								
								
									
										
											BIN
										
									
								
								Content/Assets/Bin/SM_Bin.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Assets/Bin/SM_Bin.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Content/UI/HUD/WidgetHUD.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/UI/HUD/WidgetHUD.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -36,3 +36,28 @@ void UPlayerHUDWidget::ShowHitMarker() | ||||
| 		PlayAnimation(RevealHitmarker, 0.0f, 1, EUMGSequencePlayMode::Forward, 1.0f); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| FString UPlayerHUDWidget::GetHealthbarText(APlayerCharacter* PlayerCharacter) | ||||
| { | ||||
| 	int healthbarCharacters = 5; | ||||
| 	float normalised = PlayerCharacter->GetHealthComponent()->GetCurrentHealth() / | ||||
| 					   PlayerCharacter->GetHealthComponent()->GetMaxHealth(); | ||||
| 	float adjusted = normalised * healthbarCharacters; | ||||
| 	int segments = FMath::RoundToInt(adjusted); | ||||
| 	 | ||||
| 	FString healthBar = FString("["); | ||||
| 
 | ||||
| 	for (int i = 0; i < segments; i++) | ||||
| 	{ | ||||
| 		healthBar.Append("="); | ||||
| 	} | ||||
| 
 | ||||
| 	for (int i = segments; i < healthbarCharacters; i++) | ||||
| 	{ | ||||
| 		healthBar.Append(" "); | ||||
| 	} | ||||
| 
 | ||||
| 	healthBar.Append("]"); | ||||
| 	 | ||||
| 	return healthBar; | ||||
| } | ||||
|  | ||||
| @ -6,6 +6,8 @@ | ||||
| #include "Blueprint/UserWidget.h" | ||||
| #include <Components/TextBlock.h> | ||||
| #include <Components/Image.h> | ||||
| 
 | ||||
| #include "PlayerCharacter.h" | ||||
| #include "PlayerHUDWidget.generated.h" | ||||
| 
 | ||||
| 
 | ||||
| @ -29,6 +31,9 @@ public: | ||||
| 	UFUNCTION() | ||||
| 	void ShowHitMarker(); | ||||
| 
 | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	FString GetHealthbarText(APlayerCharacter* PlayerCharacter); | ||||
| 	 | ||||
| 	UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) | ||||
| 	UTextBlock* HealthText; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user