I don't know how to get a reference to the main character so I can call the Equip function!

Hello, guys! I want the Main Character to be spawned with the weapon already attached so I figured I need to call the Equip function in the EventBeginPlay but since I don’t use the OnOverlapBegin function I don’t know how to cast it(because I don’t have the OtherActor variable)…I tried ATheGameCharacter* Main=Cast<ATheGameCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); but with no success…then I tried to do it in Blueprints


but again, no success.

This is how my Equip function looks like:

Basically, I don’t know how to get a reference to the main character so I can call the Equip function!

As I am sure you guys can help me, I want to thank you in advance!

class AYourCharacter* const ThePawn = Cast<AYourCharacter>(GetInstigator());

Thank you very much, gamepainters! I really appreciate it.