Blueprint casting from actor to widget didn't fail

In blueprint I’m using “Get all actors of Class” for my UserWidget. Taking first element and trying to cast it to my widget class. It didn’t failed. And at the same time didn’t actually cast it. I can’t see public variables from returned object.
I think cast should fail in case of casting UserWidget to Actor.

Hi ,

Can you post a screenshot of the blueprint in question? I am having a bit of a difficult time understanding what you are attempting to accomplish and a screenshot may help clear things up. Thank you!

Hi ,
I’m sorry for my english.
As you can see I have a class NewShipEditor - UserWidget (UMG). When I’m casting in from “Get all actors of class” element - casting didn’t failed, but I can’t see my public blueprint variable “hull”.
There are two ways:

  • It should fail.
  • It should give me access to my variable.

Thank you.

Hi ,

In this case, unless you have no actors of the class from the “Get All Actors of Class” in your game, you will continue to receive a succeed on the cast. What this is effectively doing is grabbing a reference to every actor of “NewShipEditor”, putting them into an array, then checking to see if those actors you just grabbed are actually “NewShipEditor”, which they will be, leading to success.

Can’t really undestand why such behaviour (successed casting) is normal.

Basically what is happening is you are getting every reference to NewShipEditor_C in your level and putting them into an array. Then you are asking the array if the first member of the array (0) is, in fact, a NewShipEditor_C. Because the only things in your array are NewShipEditor_C, it must be true unless there are no instances of NewShipEditor_C in your level, so the cast must succeed.

Ok, but then, why I can’t obtain any /geter of my variables of NewShipEditor ?

How do you have them set in the shipeditor blueprint? Can you post a screenshot of this blueprint so I can see how your variables are set up and what may be occurring?

Unfortunately I haven’t been able to reproduce this on my end. When casting to a different blueprint within a widget blueprint I was able to get any variable I needed. Do you have any steps or any information that can help me to reproduce this on my end?

Hi ,

We have not heard from you in quite some time. I am marking this thread as answered for tracking purposes. If you are still experiencing this error, please comment with the requested information. Thank you!