Mega Challange Video

My challenge video is below. I got lazy at the end and I didnt implement a second map. Also, there is not any AI improvements. But other challanges are finished. Enjoy! And dont forget to share your thoughts.

3 Likes

Phenomenal job!! :exploding_head:

Thank you :relieved:

How do you detect the Gun Actor of the player for the ammo?

Basically, I have an array to hold the guns for the player. And I have an integer called GunIndex to hold the equipped gun index in the gun array. I have write a simple function to get the current gun called GetCurrentGun (just returns GunArray[GunIndex]). With these, I simply call Player->GetCurrentGun()->GetAmmo()

Can I see the code that defines “Player”, the function “GetCurrentGun”, and the place where you called “Player->GetCurrentGun()->GetAmmo()” ? Also, what code lets the Ammo Pickup Actor detect if the Player is touching it?

Sure:

In ShooterCharacter.h

	UPROPERTY()
	TArray<AGun*> GunInventory;

...

	UFUNCTION(BlueprintPure)
	AGun* GetCurrentGun() const;

In ShooterCharacter.cpp

AGun* AShooterCharacter::GetCurrentGun() const
{
	if (GunInventory.Num() > GunIndex)
		return GunInventory[GunIndex];
	return nullptr;
}

Get Current Gun is actually a blueprint callable. So I call it in widget blueprint function:

Privacy & Terms