Added rotating Mini-Cows as Healthbar

Hi,

I know, this is a jump, but I have to be fair and need to say first, that I did the Blueprint-Course first and did have little pre-knowledge in c++ so I knew, hot to look up in the Internet and Documentation for what I need.

So…: My first thought once we addet healt / lives to the game was “I need rotating mini-cows!”

So I did:

I used an empty Actor as semi-dynamic “Zero”-Position, created a BP with the cow-Mesh and used it as Mini-Cows:

Just a “little” Blueprint-Magic on the mini-cow itself:

Here is my code:

Header:

[...]
	protected:

	//Lebensanzeige
	UPROPERTY(EditAnywhere, Category = "Lebensanzeige")
	TSubclassOf<class AActor> ALebensanzeige;

	UPROPERTY(EditAnywhere, Category = "Lebensanzeige")
	AActor* LifeCowSpawnEmpty;

	UPROPERTY(EditAnywhere, Category = "Lebensanzeige")
	float ActorOffset = 50;

	UPROPERTY(BlueprintReadOnly, Category = "Lebensanzeige")
	int32 Lives;

	UFUNCTION(BlueprintCallable)
	void DecreaseLife();

	UFUNCTION(BlueprintCallable)
	void IncreaseLife();
	//
	private:
	TArray<AActor*> LebensanzeigeArray;
[...]

CPP:

void UBullCowCartridge::SetupGame()
{
[...]

    //getting Spawndata form Empty:
    FVector LifeCowSpawnPos = LifeCowSpawnEmpty->GetActorLocation();
    FRotator LifeCowSpawnRot = LifeCowSpawnEmpty->GetActorRotation();
    FActorSpawnParameters SpawnInfo;

    //setup Lifecows & throw into Array:
    for (int32 i = 0; i < Lives; i++)
    {
        LebensanzeigeArray.Add(GetWorld()->SpawnActor<AActor>(ALebensanzeige, LifeCowSpawnPos, LifeCowSpawnRot, SpawnInfo));
        LifeCowSpawnPos.Y = LifeCowSpawnPos.Y + ActorOffset;
    }

[...]
}

It’s a bit over the top, but I like it :slight_smile:

Cheers!

2 Likes

Haha this is genius and I’m mad I never thought about this before.

1 Like

Nice :+1:

2 Likes

Thank you, guys!