No announcement yet.

Having trobule with casting to widget

  • Filter
  • Time
  • Show
Clear All
new posts

    Having trobule with casting to widget


    I'm quite new to blueprints, so keep in mind that I'm not well experienced yet.
    So let's get straight to the points, I'm having problem with casting. Mainly with casting to widgets as title says. Right now I'm making inventory system, I have quite a lot of widgets and I need to communicate between them. Most of the widgets are childs of MainWidget. Well I dunno if I should call it childs, they are placed in MainWidget designer, so basically they are variables.
    So basically if I'm not mistaken I only need to cast to MainWidget. I read that for the "object" input in Cast node is return value from Create Widget, so that's what I did. But now it says 'MainWidget is already a 'Main Widget', you don't need to Cast To Main Widget.

    Creating widget:

    Casting to widget:

    You set the MainWidget(Variable) as MainWidget so there is no need to cast it since it will contain all the properties of a MainWidget.

    Lets say I have a variable called Animal. Then I make 2 variable out of it (cat and dog). So in this case the Animal is the parent class.

    I don't need to cast Dog as a dog because dog will have all properties of a dog.

    If you casting an Animal however, you want to cast it as a dog or a cat because it could be either of the two.

    Hopefully that explains it