What do I set as 'Target' for my referenced blueprint?

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:


My own blueprint. What do I put as ‘target’, and am I missing anything else?


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?

Thank you for any help :slight_smile:

Hey @ingridbie!

Just to make absolutely sure, I reproduced this and am getting no issues. What does it say when you mouse over the error?

Also it should show the error in the Compiler Results window.


If you closed this window you can reopen it by going to Window → Compiler results. :slight_smile:

image

Hi @Mind-Brain, and thank you!
This is the error I get:

I added the First Person BP as a variable in my own BP and connected it, and then I did not get an error. No idea if thats correct though


3

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.

Where is this code being executed?

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?

Where is the code being executed?

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 :slight_smile: I’ve been using two different blueprints: BP_FirstPersonCharacter and BP_O2Dispenser (my own actor BP). Should everything be done in BP_FirstPersonCharacter?

Is the player character the BP_O2Dispenser?

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. :slight_smile:

1 Like

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:

Its the exact same I have now for BP_O2Dispenser:

The only difference is that BP_O2Dispenser is sent to BP_FirstPersonCharacter:

While BP_LightSwitch is sent to my BP_Light, which is set up like this:

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.

1 Like

That worked, this is the setup I ended up with. Thank you so much for your help!

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!

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