In my project I have some hard references to the player character in several other blueprints. - use these to get location / rotation etc and the values of certain variables like health.
I know hard references are supposed to be a big no , and that i can use an interface (message) to share the location / value of any actor that implements the interface.
The question is that for an asset like the PC which is always loaded regardless of the level is it going to be a huge drain on resources or is this instance ok?
Also is this the same logic for the controller and game mode which are always loaded when the level loads?
There are two things that can be wrong with hard refs.
Memory
Mess
1 means that anything that references your player, will always have everything concerned with your player loaded, even when your player isn’t there. This is probably not an issue, because the player is always loaded. So it doesn’t really matter.
2 It’s bad practice and could lead to messy programming if your player is referenced directly. There are degrees of this. Just cast to your player, and everything is loaded, but it’s not really bad practice. But if you’re referencing and changing variables in your player, not so good
Honestly, knowing when to break these rules is the key. I store a game instance reference in most of my actors, player pawn as well. I can’t be bothered to write interfaces for every little thing. Even if your player is destroyed, chances are what’s referencing it will be as well. But knowing your game you can make an informed decision.
Thanks for response. Looks like I am okay from a memory point of view because the PC blueprint is always loaded regardless of the level ( need to optimise the textures here to keep it very low)
With regards to ‘mess’ hehehe looks like i have some work to do. Sigh!
Thanks for the reply. True if the player is getting destroyed its a game over and main menu time. Now is it possible to load a level without loading the player . . hmm