Fill Generator only while holding Gas Can

Hello!

I want to add a blueprint mechanic where only if my player picks up the gas can I added to the game and is holding it, then he can fill up the generator actor I added to my game.

Right now, with or without holding the gas can, you can still fill up the generator, and I want to make it so where you have to be pick up the gas can first before you can fill up the generator.

The BP for the generator is here: Fill generator only if holding gas can first. posted by anonymous | blueprintUE | PasteBin For Unreal Engine

Since you’re handling input in the receiving actor, there isn’t a naturally clean way.
To do it with your current setup, you can add a branch node after setting is held that checks whether the player is holding a gas can or not.
image

Checking whether the player is holding a canister differs depending on how you’ve implemented your interaction system.
Assuming you’ve done it in your player, you’ll need to get a reference to your player (GetPlayerController/GetPlayerPawn, wherever you have the reference) and cast it to your actual player class.
If you have a boolean for whether you’re holding a canister- that’s great- use it with a branch node. If you just have a reference to canister, use the IsValid node.
If your system allows for other interactables, you’ll have to cast it to a canister as well.

If you’re still confused, please post another video going over how the interaction system works.

The second blueprint link is the interaction BP i have for my character for the gas can I have.

I’ll make another video if necessary but with these, would you be able to help? I don’t exactly know where to put what I need to add without it screwing anything else up.

Could you maybe show screenshots of any possible edits?

Ah- you’re doing it in quite an unconventional way.


Make sure to set the class in the == to be your canister class.

Constantly destroying and creating actors isn’t great- definitely look into the AttachActorToComponent node.

Okay, before i plug the BP in i just want to make sure. How did you get what i circled in the picture i sent? I want to make sure i put that in as well, also, where in the BP did u put that in? Did you put that in the genrator BP?

You have a component called “ItemActor” which I assume is a Child Actor component. I named it ItemChildActor to make it a little clearer, but it’s exactly the same as your ItemActor. Simply drag off the “As XXXXXXX” after casting the player pawn to your player class, get the ItemActor, get the child actor class from that, and check if it’s the canister.

Yes- it’s in the generator bp. Right after setting IsHeld to true and right before entering your gate.


I highly recommend looking into version control software.
There are a lot of elitists that say go Git command line or go home, but GitHub Desktop or any other software is perfectly fine. It may feel daunting, but it’s actually really simple and will save you from ever having to worry about messing something up or random progress losses (ie crashes, random corruption, making a large change you ended up hating, etc).

Hey RokenRock! You fixed my problem with the generator being filled up without the gas can. Here is the results! Thanks again!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.