Hello, you don’t need to always say sorry about that xD I also understand that feeling also when I’m new so its perfectly fine.
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = “Counter”)
uint16 CoinAmount;
You don’t want to put this variables on your PickupActor. You want that in your character class. You also want to remove all of your commented code, since it’s not in the correct class and some of it already implemented by you.
/* void OnSphereBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, Uprimi…) In my case, what should it look like???*/
In your case, this also need to be removed since you already have void OnBeginOverlapComponentEvent(…) and that is the same.
ColliderComponent->OnComponentBeginOverlap.AddDynamic(
this, &ACPT_CoinPickupActor::OnBeginOverlapComponentEvent
);
These piece of code, can be problematic if you put it in the constructor. Move it to BeginPlay() function.
AddCoinByValue(uint8 Value)
This function, also should be in your character class, not in your PickupActor class. You don’t want the PickupActor to save the coin amount. If you already have your custom character class, you should move this AddCoinByValue function and CoinAmount variable. CoinAmount will be incremented inside AddCoinByValue().
After then in your PickupActor BeginOverlap,
void ACPT_CoinPickupActor::OnBeginOverlapComponentEvent(...
)
{
if (!Cast<ACharacter>(OtherActor)) return;
Instead of Casting it to normal character, put your custom character there, and call AddCoinByValue() there to increment it.
AYourCustomCharacter* Char = Cast<AYourCustomCharacter>(OtherActor);
if(!Char)
{return;}
Char->AddCoinByValue(1)
// This 1 parameter is optional, if you want to make it without parameter it also fine