Help with blueprint communication

Hi, I’m having some problems with blueprint communication.
What I’m trying to do is basically making a fuel blueprint for the player (how much fuel does the player have) and a cone which is supposed to be a jerrycan that suppose to add fuel to the player.
BTW I’m kinda new to blueprints (i guess you already know that)

here’s what i tried to do:

The Variables in black are the variables from the player_fuel blueprint.

In the player blueprint for verifying it works good, i did that every second it will do a pring string with the value of the fuel, but it doesn’t change (when i pick it up it suppose to add 25 to the fuel value)

and for some reason I’m getting an error “Accessed None ‘Player_Fuel’ from node Construction Script in blueprint Jerrycan

I couldn’t see a problem with the nodes, but maybe some expert can help you.

In order for blueprint to work, there need to be an instance. This is the only thing I can think of why its not working.

Class Blueprint is equivalent to C++ class (hence the ‘class’ name). Like a C++ class, in order for an object of a class to work, you need to create an object or instance of the class. You can do it in BP (but its not the only way) by dragging the BP Player_Fuel into the level. You may want a billboard or something as a component so you can select it in the level. Where you put in a level is not critical.

Have you an instance of Player_Fuel BP in the level? Yes, even if its not a mesh, you need to drop a BP (say if the parent is an actor) in a level for a blueprint to work. Exception are HUD, PlayerController & a few others as they are created on game creation.

If you have, just pull the instance into the blueprint (by dragging its name from the outliner) as a reference variable, then you can change its variables. The reference variable normally will have ‘from persistent Level’ (or a defined level) on the second line of the node.

If you mean to drag it to the level, i did it already, the jerrycan is a physical object.

I’m confused…

You made a blueprint just to hold the fuel for the player? Why not just do that in your Pawn/Character?
If you do this then it’s all very simple. You can just add a function in your Pawn, AddFuel with an integer. Then from OnComponentHit, cast ‘Other actor’ to your pawnclass and call AddFuel on the output.
This way there is no need for your Player Fuel variable.

Also, you might want to wait with Destroy Actor until you’ve done all this, i’m not sure the actor can do anything after you’ve called Destroy Actor.

^

Not the Jerry can, I meant the Player_Fuel BP. Also like Thommie said, you could use a variable from your character BP.

Try dropping the Player_Fuel BP into the level. Then in the Scene outliner, Pull & drag the PlayerFuel actor into the graph, replacing the Player_Fuel reference you have now.

You know its a reference to an object in a level when there is a ‘from persistent level’ on second line of the node.

It should work. Try it & let me know.

Alright i tried that :


Still doesn’t work.

I’m doing print string just for testing it out.

I deleted it and made it in the character blueprint.

You’re getting there, but using ‘My Character’ isn’t needed. From OnComponentHit you should cast ‘Other actor’ to your character class and then use that output to increase Player Fuel.

You’re probably getting an Accessed None error since My Character doesn’t point to anything, when using a variable like that you first need to assign something to it. This is however not needed in this case since we can get the character by casting Other actor.

Thank you so much!
That’s what i did and it works:

I forgot that you can only drag an instance from level only work in level blueprint.

Nevertheless, glad it finally work out for you.

I have another problem now, lets say it’s something similiar to what i did in the last images, but just changing the value of something, without overlay which has the other actor thing to cast to the other blueprint .