Casting to a Actor

Hello

So, I have a problem. Im making a game were you are able to pick up bananas and than be able to see it as a text in the HUB. So everything is almost crystal clear, exept for one thing… I made the funktion and the variables that count the total bananas collected in a actor blueprint.

Now Im trying to cast the actor from the Gamehub to get the total bananas collected integer. But whatever I put in the object “wildcard” in the cast node im getting this message

Now I know that it works if I cast to my active character and then choose the get player character as a object. However no clue why. Can any one of you wise men help me out? And perhaps even make me understand? :slight_smile:

I believe the “Object” has to be of the Actor type.
Why are you not keeping a reference to the Banana object and reusing that?

Also you have not setup the failure case and return value.

I think when you pick up the banana you call the DestroyActor function in the banana. When you do that the banana is gone and you have to save something in your “inventory” to know that you picked up a banana and how many you have. But you dont actually add the banana actor to you inventory.
What you are doing asuming from the name of the function is trying go verify that the object you are picking up is a banana. The Cast to something is like saying: “hey, you over there, are you a banana” and then he says, yes i am or no i am not. but to ask someone are you a banana you need someone to talk with, you cant just scream in an empty room are you a banana and exept to get an answer and even if you would get one you wouldnt know who said it. So you need an actor you are talking with. By picking up you can do it with an raycast and the what you hit, if you hit something, then you ask it, hey are you a banana and it mb says no im a rock, then you do it again and again until you hit a banana and then you know it is a banana and you know what a banana can do, thats why you can access the funktion of the banana then.

You need to make a check on the banana before you destroy it. Add a reference to the banana actor on the function then drag that pin into the “Object” pin of the cast to node.