My blueprint can't access the value of a variable from another actor despite this actor being referenced in a variable

Hello,

I’m making a spawner system that i can place in my world, choose the weapon i want to spawn and when my character walks into it, he can pick it up.

My spawner is a different actor from my weapon and character blueprint, so when i want to know if my weapon (from my spawner) on the ground is pickable, i need to set the pickable? variable in my spawner blueprint, and read it in my character blueprint when i press the key set to trigger an event that will pick up the weapon, set in the weapon blueprint, as seen below.

In my Character blueprint:

In my weapon blueprint:

In my spawner blueprint:

My problem is that in-game, after trying to pick up a weapon (which doesn’t work) to leaving the editor, i get an error message saying:

My character blueprint seems to consider that my pickable? variable is not set, maybe because it is set in another actor, but i don’t get it since i’m taking the variable direrctly from actor it is set at, i tried doing the same but with a cast to instead of creating a reference variable, which removes the error but a print string placed before the call for the pick up event in my Character BP shows that it still can’t read the value. I would be really grateful if someone could at least explain how to properly read variables from another actor inside a blueprint.

Thank you.

The error says the the WeaponSpawner variable in the character is null. From the images shared I don’t see where it is being set. Can you post that part of the blueprint?



Also, unrelated to your issue; the PickableWeapon variable should be set after the spawn node, not when the overlap executes.

Oh i never thought about setting my weapon spawner variable, that makes so much sense now but that makes it so much more complicated because i don’t know how to set it, since the type of my spawner variable is my spawner. Maybe this isn’t the right way to make a pickable weapon system, but i don’t knoow how to do it better, i really thought this was the best way given the structure of the weapon system.

About the pickable?, the thing is i want to set it to true when my character overlap the spawner hitbox , if setting it to true after the overlap isn’t the right way, how can i do it ?

I suggest you check out the 1st person template to see how its setup there, it includes some pickup logic.


On another note IMO the character should not be aware of the spawner at all. The only thing the character needs is a variable that holds a reference to the picked weapon parent class, if anything.

If you want the spawner to be informed when the wepon it spawned was picked up, then I suggest you place a dispatcher in the weapon that the spawner can listen to. So when the dispatcher fires the spawner can start a timer to spawn a new one, for example.

Thank you for your suggestions, i looked inside the firstperson template, but it didn’t really help me, but it doesn’t matter because i found another way to do it that doesn’t involve a spawner but directly pick up a weapon that i place inside my level, it’s the system i wanted to make originally but i never really got it working until now, it’s still not working properly but i think i’m close. Thank you a lot for your help and the advices about the structure of my blueprints.