i want to know how to use this blueprint code
So for example you have Player Inventory and Some AI NPC trying to steal something from player. So the function will be like: get array of items from Inventory, sort them and get most valuable item. What if player inventory is empty -then the array is empty and function can’t return valid state. Or NPC have reference in Blackboard to his TargetToFollow Actor and then this Actor was destroyed so the reference variable will be no longer valid for the next update.
Hey Whisper,
Both of the IsValid node’s perform a Null-Check, which essentially means it makes sure the object reference used as the IsValid input (usually a variable) holds a valid reference to an object. If the variable is un-set, meaning null, it will either use the not valid output from the executable macro node (white wires), or will return false if using the function node that outputs a boolen value (red wire).
To use it with the function node just add a branch node and use the boolean return value from the IsValid node as the input for the branch node, or use the inline macro node as the branch so you have 2 outputs, one for normal execution, the other to handle the error and move on.
It’s most often just used to check and make sure the object is loaded properly before you try and use it. The fact that it can handle certain errors for you is a bonus!
Hope that helps!
thank U so much,i will try it!