u/MNREDR

I don't quite understand 'hard references' and how/why to avoid them

I keep seeing that 'hard references' such as casting should be avoided or at least reduced as much as possible, but I don't really understand why. Apparently when you hard reference an actor, everything that it references is also loaded. But in my project, I cast to game mode, game state, pawn, player controller, interactable objects... etc, and all of these actors are already in the game and referencing each other at any given time, so should casting still be avoided? Is it because references are stacked somehow and will only accumulate over time with no way to clear up the memory?

Another issue I don't understand is using event dispatchers/delegates vs directly calling a function through an actor reference. I understand that delegates are good for when you want multiple things to react to a high level event, like multiple UIs reacting to a change in game state, but what about a player controller updating the game state? To me it seems intuitive to directly call the game state's function from the PC, but that again creates hard references that apparently should be avoided.

What are the best practices around this?

reddit.com
u/MNREDR — 1 day ago
▲ 1.6k r/BLAHAJ

My mom brought him in a bag so he wouldn’t get hospital germs on him but I ended up taking him out so I could cuddle him better. I still sleep with him every night 🦈

u/MNREDR — 17 days ago

Hello, I’m new to replication so any help is appreciated.

I have a server owned ball that when a client character picks it up, the ball attaches to their first person mesh. But I want other clients to see the ball attaching to that character’s third person mesh.

Is it possible to do this while keeping the ball owned by the server? Or should I change its ownership to the player that picks it up?

reddit.com
u/MNREDR — 20 days ago