Disable Function if Target is not Valid

Hello Devs,

I’m working on a project which makes use of multiple pawns. The logic which drives their movement is being held in the player controller.

Problem is: when a pawn is killed to transition to another, the controller movement functions still look for their target and an error is returned. “Accessed None”

I use a branch to disable the input to the function, but the function still looks for a valid target, even if it is not receiving input. What approach is best to keep the functions happy when not in use?


Hey Vince!

Have you tried IsValid functions? One of them lets you pass input depending on validity of the actor, the other gives you a bool.

Hey Jacky! It’s been forever since we last chatted.

IsValid did the trick! I used the Input variety upstream of my ownership bool. I guess the bool is redundant for now, but it’s working nicely.

So it seams like there is a difference between a Branch “not firing” and a IsValid not firing?

Thanks for the tip! Now that I’m back to developing on my own, you’ll be seeing a lot more of me around here. haha

Yeah, it’s been a while. :slight_smile:

IsValid with bool is just an alternative to the input one as far as i know, so you can use either one of them. IsValid checks if the object exists in the game or not so it prevents any kind of errors you may have when you try to send input to a destroyed/not yet spawned object.

Cant wait to hear more about your project!