Blueprint Actor to ThirdPersonCharacter Communication

I’m trying to have this weapon blueprint communicate and share the “Overlapped?” boolean with the ThirdPersonCharacter and I cant find anything to put in the object (the tpcs) and I’m having trouble finding solutions to this online.

1 Like

You can use “GetAllCharactersOfClass” then select player character (or whatever class it is in your setup), then pick first element from array. Bu this is borderline hax, and may cause problems in future.

More proper way is “getPlayerCcharacter” reference and use it

Or best imo (because you see all code and you can decide how it behaves) is to use “game mode” blueprint.
Is in “Begin play” in player character to get reference to “game mode” then store player reference there.
And your weapon should read that reference from inside game mode, then get that variable value from player character bp.

Also why I think game mode should be used:

  • central place for all beetwen blueprints communication, so you can debug everything in there
  • easier to track what references what
  • and as i said you have this code visible, you know what is going on. For eg in case of built in multyiplayer system and player references, it is not always easy to track what is wrong when for eg. player0 on client is different than player0 on server (just example not sure if that is the case).
  • all dispatchers should be placed in “Game mode” blueprint for same reasons. You get all dispatchers code inside single BP. Then add EVENTS to update variables or trigger dispatchers.

In big projects it is very easy (esp with blueprints) to lose track what is where. Text scripting is more condensed, but blueprints tend to be huge and span huge areas. So keeping all organized even with a bit more extra code is worth it.