How do you access a class member of another class from a separate class

Hi so im currently trying to access a member of a game mode class from a Character class and ive been having problems getting it to work, i have looked around but i haven’t much that i understand i tryed to cast my game mode class to my player class but i haven’t been able to get it to work i also don’t want to get the current levels game mode just one specific one, could some shed some more light on how to use cast like do i have to #include a specific module to use it or does someone know a simpler way to access the variables of another class

Hello! Unreal’s CAST is very similar to C++ cast. It is just make a child class pointer from parent class pointer, so after casting you can use child functionality.

“i tryed to cast my game mode class to my player class” - you cant do that, because game mode class is not player class at all!

if(AMyGameMode* myGameMode = Cast(GetWorld()->GetAuthGameMode()))
{
myGameMode->myMember = 0;
}
you can get the gamemode like this