Hi, I have a Ball actor which destroys Cube actors in game. I want to increase a score every time a Cube is destroyed. Score is a Text Widget. I think my problem is in referencing Ball actor in the Score Blueprint. Here’s what I have so far:
First, I made a widget in Ball BP:
Then I made a function for counting score. This is in Ball BP as well:
(This function currently prints the score as string on the screen. It’s for testing purposes before the Text Widget is working)
Then I created Widget BP and added a Text widget for score. I set it as a variable called Score. I also made function called UpdateScore which increments the score. I have this function connected to the Event Tick of the Score BP:
The thing is that I get the score updated each frame on this way. Each frame the function UpdateScore increases score by 1. But I have a problem when I try to make my Ball object update the score by 1 once the Cube is destroyed. I tried to do it on this way:
This is how I tried to call and reference Ball Actor in the Score BP, but I get the warning that you can see on the picture. I assume that this warning is the reason why I can’t update the score once I destroy the cube. But here’s also the modified UpdateScore function which now calls Ball actor and uses variables from it.
I tried adding the Ball actor reference and then getting the ScoreVar, which is variable from the second image that keeps the score in the Ball BP which prints score correctly on the screen via Print String. But instead of getting the updated score each time a cube is destroyed I just get the initial value, which is zero, once I start my game.
So can you please tell me what am I doing wrong here? I’m beating my head pretty much the whole day on this thing and I still couldn’t solve it. I read many things on here, but some of them use some stuff that I still haven’t learned so I don’t know how to implement it. This is my first time trying to do something in Blueprints.
Also the third image where I only use logic inside Score BP without calling anything from Ball actor is just to see and show that everything is set up properly for score to update but that the referencing and calling from Ball actor is where I made a mistake and don’t know how to do. So, the last two images are a problem.
Thank you in advance, and sorry for long post.