Hi!
I called my TileConquered function in a slightly different location than Sam did, and I found my way to be much easier so I wanted to share it with the rest of you.
I ended up calling it at the end of the OnComponentEndOverlap event for the barrier collision, after the Lock function call, as opposed to OnComponentBeginOverlap. Since EndOverlap also calls the Lock function, which enables collision on the barrier, it is impossible to walk back through the barrier to get more score. Setting it up this way saved me from both making a new variable and adding several nodes to my event graph.
For clarification, I have attached a picture of my implementation below.
Also, for those of you who wanted to create the function in C++ and are having trouble, I will include code for my C++ implementation:
void ATile::TileConquered()
{
auto GameMode = Cast(
GetWorld()->GetAuthGameMode());
if (GameMode)
{
GameMode->NewTileConquered();
UE_LOG(LogTemp, Warning, TEXT("Score: %d"), GameMode->GetScore())
}
}
P.S. - Feel free to follow along with the lecture instead of using my code; I understand that itβs a matter of preference and again, this is just what I found easier.