Hi,
I have this game where I control pawn from player controller through a reference, and relaying the input indirectly, as the player will be able to control multiple pawns at a time. There are some other level elements that rely on a reference to this pawn. The pawn can be destroyed, and at that point, the reference becomes invalid and message log throws error. So I have added validity checks where appropriate.
I do the validity check every tick. It appears however, that the input is processed prior to every tick, so if I send an input to an invalid actor, I still get one or two errors before validity check through the tick actually catches it.
I am sure people deal with these trivialities on daily basis, so I wonder what is the most common way to handle this?
I thought of adding the validity check on the InputAxis event, but my intuition tells me that using a random axis event in a player controller to do validity checks for an actor many objects in the scene rely on is a bit awkward solution. Also, I don’t know what the order of the InputAxis events is, so to ensure the check works, I’d have to do it twice on both axes, and doing two validity checks each frame feels like a waste.
Thanks in advance.