Announcement

Collapse
No announcement yet.

Issue Gaining Reference to Child Widget Class from Parent Actor Class

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Issue Gaining Reference to Child Widget Class from Parent Actor Class

    Good Morning,

    First post ever so I hope this is the correct place. I am into my second month of converting over from Unity and I am really loving Blueprints. However, even after watching a ton of tutorials on referencing, I can't figure out how to gain access to a child objects class and not the component. Let me explain.

    I have an Actor Class called Touchspot Object.

    I then have a Widget Class called Touchspot Object Icon. This is simply a Button with an image assigned to it. This button also has a Fade In and Fade Out animation.

    On the Touchspot Object I added a Widget Component of class type Touchspot Object Icon.

    I was then able to drag the Touchspot Object into the scene and press the attached Touchspot Icon Widget Button. Any code assigned function as expected. However, thats when things sort of got complicated. I have (6) Touchspot Objects in the scene. Each one of them speaks to a different Item in the scene when its Touchspot Object Icon button is pressed. I have a public variable that I used to drag the objects each one needs to speak to. I also added an exposed Integer value that I can use as an ID of sorts, which I assign each object in the editor.

    This is where the trouble is. When an objects Touchspot Icon is pressed I call an Event which is defined in Touchspot Object. This event simply checks the ID and the fires off another event which takes that ID as an argument. The final object takes that the ID passed to it from the Touchspot Object and uses it in an enum to do whatever.

    I cannot seem to get a reference to Touchspot Object from Touchspot Icon. I created a variable of type Touchspot Object and linked that to the target connection of the event node. On the Touchspot Objects event node I just linked a print node to see if it even works. It does not work at all and I am getting no errors.

    I also wanted to play the fade animations of from Touchspot Icon from Touchspot Object but I can't get access to the class. It says it doesnt inherit from the Widget Compnonet.

    I hope that was clear enough. This is kinda important since it is for a job. What am I doing wrong?

    #2
    In case someone needs this I was able to figure out how to get reference to the Widget Class from the Actor Class. I am still working on the other way around.

    Click image for larger version

Name:	Untitled.png
Views:	29
Size:	94.2 KB
ID:	1706785

    Comment


      #3
      Now I am trying to figure out how to gain access to the Parent Actor BP variables from the Widget Child BP. That is the last part of my issues.

      Comment


        #4
        Sounds like you need to use the node: Get User Widget.
        But I have to admit, I got a bit lost trying to read that dude...

        EDIT: Too late, page needed reloading. Anyway as to the second part... The variables are inherited. To see them all, tick on 'show inherited' vars at the top of the variable pane... To override functions but still keep the functionality from the parent... Right click on Event Begin Play or Event Tick and choose execute / call Parent etc...
        Last edited by EntrpriseCustomr; 01-10-2020, 12:56 PM.

        Comment


          #5
          Thanks. I will try that. I ended up just defining the reference in the parent object on Begin Play with a quick delay. Since I needed each Touch Obj to talk to its own parent it seemed like the right option.

          Attached Files

          Comment


            #6
            I guess this should be considered SOLVED for Google keyword purposes.

            Comment

            Working...
            X