'Accessed None' with public variable for spawned actor

I need to spawn an actor into the world which should read a public variable (in this case, a user-input string), but since it spawns, I can’t find a way to point the spawned actor towards the actor that owns the public variable (a virtual keyboard).

The spawned actor is sort of a ‘settings summary’, it’s created after the user inputs various pieces of information with a virtual keyboard and option drop down menus, and needs to display the results of all of this user input which it reads via public variables of other Blueprints. It needs to be dynamically spawned because an indefinite amount of these need to be created by the user.

With actors placed in the game, the drop down menu in the Details pane solves this issue, since you can tell it which actor in the class you want it to be able to communicate with (see image)](http://i.imgur.com/WnlyJQW.jpg). My spawned actor is spawned at run-time and so there’s no way to define this - it needs to be done in the construction script, but how?

i don’t known if understand right your question. I do a VK and spawned without problems

you can’t keep of the spawned keyboard in one var?

I can spawn a virtual keyboard in two ways, from character, or from a button (other actor), without any problem.

if you have 100 VK spawned in other way in your world you can get a reference when character touch the VK

So let’s say, this is what I have:

Blueprint01 with integer variable called NumberOfPies that is set to public, and set to 9

Blueprint02 which needs to retrieve Blueprint01’s NumberOfPies variable, but Blueprint02 dynamically spawns in the world.

If I create a reference to Blueprint01 inside Blueprint02, and call its NumberOfPies variable like so:


It doesn’t work, because I can’t set what instance of Blueprint01 I want to request that data from unless I place Blueprint02 in the editor, where I then get this drop down menu:

BUT, Blueprint02 can not be placed in the editor, it has to spawn in the world at run-time.

and blueprints01 its already in the level no?

You can “Get all actor of a class” in the world but have his problems in some situations but its hard known what do you exactly have in mind hehe

not sure how your planning your logic, but sometimes its better not try break a rock that blocking your way because sometimes its impossible in that way and the better its rethink all again and choose other way.

Try Get All actors… that work for get the bluprint01 instance reference and if you have other problems perhaps its better rethink how all that going to work together.

The simplest way I can explain is that I need to spawn actors during game play that read public variables from other actors.

Well said, I may well end up doing this :smiley:

And yep, Blueprint01 is already in the level. I’ll try the Get All Actors, it sounds like it is exactly what I need, I’ll test it later.

Thanks for the help!

If the actor is reading a variable then I’m going to assume you are setting a variable on the actor. Whatever variable you are setting, enable editable and Expose on Spawn.

What this does it exposes the variable on the SpawnActor node, allowing you to plug the public variable directly into the node

Exactly like I have done it in this picture. You can see I take multiple inputs and plug them directly in my SpawnActor, which has logic on Construct and Begin play to set the values I input.

I do this because it allows me to customize projectile properties in the weapon blueprint, I don’t even have to touch the ProjectileBP

This works! Thanks for taking to time to explain.

I think this has solved my problem for all scenarios where I’d need it, but just out of curiosity, what would you do to have the spawned object read the variable again, or another variable after it has been spawned? I tried with Get Actor Class, and it seemed like the right thing to use, but I couldn’t seem to plug in its return value to tell the spawned actor which specific actor-in-class I wanted to read the variable from.

I’m not too familiar with Virtual Keyboards, I’m going to guess you were just setting a String from it? In the Actor itself you could also set a reference to the keyboard actor on spawn. Not 100% sure

Since you would have the keyboard actor reference in a variable you should be able to use an Event to do whatever you wish with it