I’m new to blueprinting, and could use some help with some basics!
I want a variable I have made inside BP_FirstPersonCharacter to be set to 100 (its default value) when pressing “E” inside a certain area, but I don’t know what to put as ‘target’ in my own blueprint. Here’s what I have:
Inside BP_FirstPersonCharacter. When OxygenRefill happens (pressing E inside the box area) the oxygen level should be set to its default value and a string will be printed, or at least that’s what I’ve attempted to set up. Is it correct?
If that is an okay way of doing it though, my blueprint still isn’t working. The print string I showed earlier doesn’t react, so something isn’t connecting properly, but I have no idea what.
It shouldn’t throw that error if this is being done on a BP_First Person Character. Are you getting a reference to self and setting that as the “FirstPersonCharacter” variable in the Beginplay?
Do you mean what blueprint it’s in? It’s in an actor BP I made, I haven’t done anything else than add the nodes in the screenshots. Not sure what you mean by this, let me know I’ve been using two different blueprints: BP_FirstPersonCharacter and BP_O2Dispenser (my own actor BP). Should everything be done in BP_FirstPersonCharacter?
Any input (such as your ‘E’ Key here)
Needs to be on the player’s controlled actor.
If the O2Dispenser is a static thing in the environment, then no, it should not be on that.
So what I’m seeing is you have the action on an actor in the environment, and you’re trying to have it affect the player. This, by design, will not work. Because it doesn’t know what to affect- that’s why the “Target” was necessary. You have to point to the specific instance of an actor- the “Object”. You’re saying “Do this to person” and it’s asking "Ok but there could be any amount of those- WHICH person?
I would suggest seeking out a tutorial for interact logic (such as “press E to activate”) to proceed. And more than anything- communication between actors is so incredibly important- reference this document until you no longer need to.
Thank you for your help, I will have a look into the document you linked. Feel free to not reply to this, I really appreciate all the help and will work to learn more on my own.
I do not understand why every input such as the E needs to be in BP_FirstPersonCharacter. I did a simple light switch on/off BP as well a few days ago, and had the E input in one BP and the executed event in another, and its basically the exact same setup I have for the current thing I’m working on, only different names.
This was my setup for the E input toggle in BP_LightSwitch:
I’m obviously missing something, but to me it seems like the exact same setup, I don’t understand why its not working in the oxygen-setup when it works in the light switch-setup.
Ah, it’s because with the BP_Light switch you are assigning the light to use. Also, it is looking for any E key press at any time throughout the game while the object exists.
That sort of input is generally for things like “Esc” or “Start” for menus, because they bypass all context.
if you really want to do it that way, you can use “GetPlayerPawn”, cast to “BP_FirstPersonCharacter” and then set your variable “Firstpersoncharacter” to that. Do that in Begin play. Then it should work- but it will work everywhere as long as that canister exists in the world.
The issue here is you need to work on your ability to have things sense the world around them and have them interact- for instance, you can do a “GetDistance” between the canister and the player, and if the output float is greater than, say, 300, do nothing, and if it is less than 300, refill.
My problem was that I did not understand the difference between referencing the first person character as a BP variable directly in my BP_O2Dispenser, instead of getting the player character and casting it. I think I understand the difference now, thank you!