Announcement

Collapse
No announcement yet.

[BP Comm] Can someone explain this to me?

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

    [BP Comm] Can someone explain this to me?

    While working on my inventory system i stumbled across an odd issue.

    This works perfectly:
    Click image for larger version

Name:	0f3bf28486.png
Views:	1
Size:	133.4 KB
ID:	1141920
    Click image for larger version

Name:	518823242c.png
Views:	1
Size:	350.6 KB
ID:	1141924

    However the following gives out errors after playing in the editor (Accessed none errors pointing to an empty construction script):
    Click image for larger version

Name:	8c72ccc908.png
Views:	1
Size:	127.6 KB
ID:	1141921

    This also does not work, and the cast fails:
    Click image for larger version

Name:	a4be693936.png
Views:	1
Size:	141.6 KB
ID:	1141922
    Click image for larger version

Name:	43218dbc1e.png
Views:	1
Size:	10.5 KB
ID:	1141923

    It's not an issue since i've figured out how to make it work, I'm just wondering if somebody could explain why this happens? It compiles just fine.
    Does the UMG widget have the player character as an owner, and therefore has to use the reference created inside of the player blueprint?
    Last edited by Xendran; 12-16-2014, 09:56 PM.

    #2
    Did you specify the player when you created the HUD, or let it just choose for itself? I think it defaults to 0.

    Comment


      #3
      Completely forgot about this little thing here:

      Click image for larger version

Name:	2cc2fe6aea.png
Views:	1
Size:	42.0 KB
ID:	1062221

      That might explain it?
      Really does seem like an ownership thing, with the second setups trying to modify a nonexistent hud belonging to the item, rather than the player's hud.
      Last edited by Xendran; 12-16-2014, 08:45 PM.

      Comment


        #4
        Hello,
        In first picture you use the begin overlap to drag your hud for your end overlap set visibility. It may be better to use the one drag from the cast from the end overlap. I have no more idea to help sadly.

        Comment


          #5
          While i appreciate the offer of help, please read the thread fully. I'm not looking for help implementing anything, I'm looking for a definitive explanation as to why one method works and the other doesn't so i can use that knowledge to make further blueprint communication attempts easier / less trial and error.

          As is clearly stated above the first image and below the final image, i have it working perfectly already.

          In regards to the end overlap cast, that cast node is actually gone now as it doesn't even need to be there at all. If you have started an overlap, that means you've already succesfully casted and there's no way to cause the end overlap event without having previously triggered the start overlap event containing the successful cast.
          Last edited by Xendran; 12-16-2014, 10:01 PM.

          Comment


            #6
            Ok so I'm going to try and explain why one method works and the other doesn't. It all boils down to references and variables.

            By default when you have a variable of a BP/Actor type they are all ways set to "Null" unless set at some point within the script. In the bottom two images that you said you were having issues with, this is most likely because the variable "GameHUD" has nothing stored in it. When you create variables like these just think of them as empty boxes, they remain empty until you put something in them. This is why you get the "Accessed None" type error message from the first of the two images.

            As for the second one I first need to explain what a "Cast To" node actually does to explain why it fails. In UE4 you get a lot of primary class types that all other blueprints build upon.

            The best example is "Actor", this covers things from player character to that dancing road cone you've all ways wan't to make. These them selves will however have there own classes/blueprints that has one of the primary classes as a base class. A "cast to" in a way changes how UE sees the reference, changing it from Actor to say DancingCone. This then allows you to access variables that have been created in the DancingCode BP.

            If the Actor reference I'm trying to get UE to see differently has nothing to do with what I'm casting to it'll fail. It's like trying to fit a cube through a triangular hole. However in the second imaging this most likely fails because the variable "GameHUD" is just an empty box of "Null" which will always fail a cast as it doesn't fit through the hole.

            In the very first image that worked you getting an "Actor" reference the overlap event spat out and telling UE to see if its actually "MyCharacter" BP. If yes you then tell it to get "GameHUDWidget" (created inside the "MyCharacter" BP) and use the contents of the box as a target. I would imagine you set the variable to the widget you created.

            In addition a variable of type "MyCharacter" for example doesn't need to be "Cast To" "MyCharacter" to access the variables from the reference.

            I hope this helps. I'm still trying to find a good way to explain the whole casting thing so I can make an in depth tutorial, so if you like the explanation let me know.
            Looking for blueprint tutorials? Then visit my blog... voxagon

            Comment


              #7
              Okay so basically what i've learned is that i need to pay more attention to what I've done -_-
              At some point, i removed the nodes that were actually setting that variable to my players HUD widget, and the errors it was outputting were pointing me nowhere.

              I understand what casting is and how to use it, as i use casting extensively in maaaaaany parts of my game, this was just a dumb mistake that happened because i forgot something i had done. That's why i was so confused as to why it wasn't working :P
              Last edited by Xendran; 12-16-2014, 10:53 PM.

              Comment

              Working...
              X