Announcement

Collapse
No announcement yet.

Creating Widget Blueprint With Variables from C++

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

    Creating Widget Blueprint With Variables from C++

    Here is my code, I am setting the value of Coins 96 but the result in widget blueprint is being 0. can anyone solve the problem? I will be appreciated

    Click image for larger version  Name:	anan1.PNG Views:	1 Size:	65.8 KB ID:	1609582


    Click image for larger version  Name:	anan2.PNG Views:	1 Size:	76.5 KB ID:	1609583

    Click image for larger version  Name:	anan3.PNG Views:	1 Size:	360.8 KB ID:	1609584
    Last edited by Tgtnoka; 04-18-2019, 04:49 PM.

    #2
    Are you setting "New var 0" to an instance of a class? If it is not valid it will just print out 0.

    Comment


      #3
      GarnerP57 hey thanks for answering, how can I do that?

      Comment


        #4
        Well first you need to get a reference to the instance of "APickup" you are interested in. There is many ways to this.

        If you already got a reference to the pickup on the Character just get it through the Character like "GetPlayerCharacter" and cast it to your type of character and get the pickup reference to be Set in your widget.

        If the pickup reference is not saved on the character but the pickup is Attached to the character you can find it with "GetAttachedActors"

        If the Pickup spawns its own widget when it gets Picked up by someone it could also be done by using "CreateWidget" and the return value is the Widget and you then have APickup set itself (self) as "New var 0" on the widget. This is the reverse of the two other examples since now the work is done in the Pickup Blueprint instead of in the Widget Blueprint.

        ps. Make sure you rename "New var 0" to something meaningful.
        Last edited by GarnerP57; 04-19-2019, 11:00 AM.

        Comment

        Working...
        X