This is a very broad question that doesn’t have a succinct answer. I recommend watching Zak Parrish’s video on blueprint communication. It’s all in blueprint, but the concepts are the same.
As far as casting syntax, you’ll typically want to use a templated cast like MyCharacterClass* MyCharacter = Cast<MyCharacterClass>(PointerToObject)
. How you get the PointerToObject
is up to the way your game works. If it’s something you’re going to access a lot from various places, you might consider having the character register itself on the gamemode, or some management class on BeginPlay(). You can also use the TActorIterator to iterate through all of the actors in your world, but that’ll be a lot slower.
Best,
Jonathan Lambert