# How do you set the instance of an object within another object?

**URL:** <https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315>\
**Category:** Blueprint\
**Tags:** unreal-engine, instances, objects, UE4, Blueprint, question\
**Created:** [September 23, 2018, 2:37am UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315 "2018-09-23T02:37:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salmon\_King9907](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Salmon\_King9907](https://forums.unrealengine.com/u/Salmon_King9907)\
**Post date:** [September 23, 2018, 2:37am UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315/1 "2018-09-23T02:37:13Z")

</div>

Hi!

Currently I am trying to make a game with two goals and a ball where two teams try and score. My current problem is I have a game master set up to handle all of the things going on within the game but I can’t figure out how to set references to my two goal trigger boxes within the game master blueprint.

I tried setting them on beginplay but when the game starts up it gives me an Accessed None error.

What am I doing wrong here? Both trigger boxes are in the world so they exist. I am fairly certain I am just setting them wrong.

 ![254460-yes.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/6/ee6275399e1cdf5995822334bbc88b91c16bd25b.png)

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [September 23, 2018, 3:46am UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315/2 "2018-09-23T03:46:18Z")

</div>

how are you setting your variables? is the blueprint that your showing one that is placed in the scene? what is this game master blueprint that your mentioning? is it one you made or is it something like the game mode bp?

the setup of this blueprint will determine how to get the references. for example if you place this bp in the scene then you could use a public variable to set the values. if this bp is a game mode then you could easily use the level bp to get the reference then set a values in the game mode. but it all depends on how you have things set up now.

---

<div class="post-metadata">

**Author:** ![Salmon\_King9907](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Salmon\_King9907](https://forums.unrealengine.com/u/Salmon_King9907)\
**Post date:** [September 26, 2018, 7:53pm UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315/3 "2018-09-26T19:53:09Z")

</div>

So the way I currently have it set up is the game master is it’s own object that is inserted in to the world. The ball is spawned once the game starts, so I can’t use the level blueprint because it doesn’t exist in the world until the game starts (or is there a way to do set instances in the Level Blueprint when they don’t exist yet?).

Currently, I have a variable of each goal created inside of the Game Master and I set each of them to an instance of the goal from the drop down and then attempt to set them at being play with the blueprint shown above. When I do this though, the cast fails and I get a return none error.

The Game Master itself is just an empty actor that handles the score variables and interaction between objects.

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [September 26, 2018, 8:10pm UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315/4 "2018-09-26T20:10:24Z")

</div>

If your goals are already in the level you can easily use the Level BP to create a reference to them. If the goals are spawned from another BP then that would be the easiest place to store them as a reference and pass that data along to the BPs that require it. You can’t set a variable the way you are doing it anyway. All you have done is create an empty place holder for the “type” of data you want to store (ie the goal BPs) but you haven’t actually provided a “reference” to the goals. You would need to use a “get all actors” node, the level BP, or some other method to get your “game master” to be given a reference to those actors. You could also use the level BP to spawn the game master and have it pass the references through to the game master on spawn this way you benefit from the level BPs convenience to create references but maintain the flexibility of doing all the work in a BP that is easier to access by other BPs (the game master in your case)

---

<div class="post-metadata">

**Author:** ![Salmon\_King9907](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Salmon\_King9907](https://forums.unrealengine.com/u/Salmon_King9907)\
**Post date:** [September 26, 2018, 9:34pm UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315/5 "2018-09-26T21:34:23Z")

</div>

The “get all actors” node I believe is EXACTLY what I was looking for. I am not at my house yet so I’ll try it once I have access to my laptop but this has helped me a ton either way! The goals are already present but the ball is not and essentially I am trying to use the game master to process the logic of the ball overlapping the goal but I need to set a reference to both and didn’t really know how to do that within the Game Master BP. I’ll try this out when I’m home

---

<div class="post-metadata">

**Author:** ![Salmon\_King9907](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Salmon\_King9907](https://forums.unrealengine.com/u/Salmon_King9907)\
**Post date:** [September 27, 2018, 6:31pm UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315/6 "2018-09-27T18:31:18Z")

</div>

So this is how I set it and it seems to work perfectly. Let me know if there’s something wrong with what I’m doing here.

Thanks again!

 ![254873-example.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/7/aa705795a3883a3e554d0127fb99356bee4b071c.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_287bd48e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_287bd48e1](https://forums.unrealengine.com/u/anonymous_user_287bd48e1)\
**Post date:** [September 28, 2018, 11:59am UTC](https://forums.unrealengine.com/t/how-do-you-set-the-instance-of-an-object-within-another-object/434315/7 "2018-09-28T11:59:28Z")

</div>

If you expose both red and blue goal variables in your game master blueprint (instance editable), you will be able to click on your game master instance in your map and see in the details panel that you can select an instance for each of those exposed variables, just click the dropper icon next to each property and then click on the red/blue goal in your world and this will setup those instances without having to find them yourself at runtime.

> **[Set and Get an Actor Reference](https://docs.unrealengine.com/5.2/en-US/set-and-get-an-actor-reference-in-unreal-engine/)**
>
> Using Actor Reference to move different Actors around in a level.
