How do you check if a parent BP is a certain type?

Hi everyone, I am working on object inspection functionality for a mobile game. To set the scenario, the player walks around a room, and touches an object. OnTouch, the GetObjectUnderThumb (or something like that, I’m not at my computer right now) command is called and I get an object from it that the player touched. Now to determine whether or not it should be allowed to be inspected, I need to check if it’s parent BP is InspectableObject. (The child BPs might be things like Lamp_BP or Photo_BP) I know that if you have the parent, you can try to cast to the child (the classic “I have an animal, try to cast to a tiger”). But if I have the child and I want to know if the parent is InspectableObject, would i still use casting? Thanks in advance!

Hello Aclemo,

yes you would still use the cast, ASSUMING, that the object you are being given, from the function call you are talking about, gives you the bottom (or low enough in the chain) of the parent/child replationships, such that a cast would function.

One other idea that comes to mind, that makes you independent of what the engine gives you in terms of an object. Is that you could have all inspectable objects that you create, have a tag that you could just query, if tag found, it’s inspectable, if no tag, then of course not inspectable.

Hope this helps,

Thank you for the solutions! I’m going to give the tag option a try, as it sounds like the … “safer” (maybe the word I’m looking for?) option from your description

I personally would go with the tag, as that would get me away from any dependence on the “cast” check. I would also tend to think that it would be quicker, in that there would be no need for “introspection” as well as, it’s should just be a quick check of a static array (hopefully an array of pointers to the strings).