x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.20
Tags:
more ▼

asked Nov 16 '18 at 04:48 AM in Blueprint Scripting

avatar image

aclem011
40 3 3 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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,

Jay

IceWare

more ▼

answered Nov 16 '18 at 04:55 AM

avatar image

jayice
1.4k 41 28 56

avatar image aclem011 Nov 16 '18 at 09:21 AM

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

avatar image jayice Nov 16 '18 at 12:41 PM

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).

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question