Have a Boolean in Actor affect player character.

I have an oxygen system for when I enter a physics object, my character’s oxygen decreases. I also have a scuba tank, which I want to stop the decrease of my character’s oxygen. Although, I don’t know how to correctly have the variable I created in the scuba tank BP to affect the player.
How do I fix this? (Red circles are the scuba variables)


^Scuba gear BP^

^Character BP with oxygen decrease^

Hey @Villager-13!

So what’s in these pictures looks fine. You may want to throw in some checks like printstrings to try to localize the issue! Check and make sure the reference is getting set correctly, et cetera.

So the variable, “Has Scuba”, is not checked when I get the gear as shown this this image. It doesn’t automatically check the variable to be true as I found like to to be.


Yeah so you’re starting with it false, but the pick-up isn’t changing the variable. Try to make sure the reference is being set. Try doing a “Printstring” node before the “Set: HasScuba? Target: Char Ref” using CharRef as your input. Just plug it in and it should convert. Then try the game, if it prints the name of your character when you get the scuba you’re good, if it doesn’t, it’s your reference.

So as it seems, the reference to the player character does not connect to the actual first person character. How do I fix this?

@Villager-13
Can you show where you are setting that Char Ref? I assume on BeginPlay?

It is actually at a gate on a box overlap. That is overlapping the scuba gear then interacting with it that has the reference.
Both the print strings show up, so It really is the reference itself.

Can you show where you are setting that Char Ref? I assume on BeginPlay?

This. You never Set the reference, at least not in the pic. Aren’t you getting Accessed None errors from the above?

image

Creating a variable does nothing unless we tell it whose data it’s supposed to hold.


Also, something like Interaction should be handled in the player BP, not in the target object. It’s the player that comes over and interacts with it, right? Otherwise you will need to implement logic in every object in the game. Or only once if you do in the player.

Doing exactly this as pictured will likely fix your issue! :slight_smile: